Page MenuHomeFreeBSD

asa: Rewrite to fix line termination issue.
ClosedPublic

Authored by des on Jan 5 2024, 1:28 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 5 2024, 9:24 AM
Unknown Object (File)
Sep 30 2024, 6:13 AM
Unknown Object (File)
Sep 28 2024, 1:39 AM
Unknown Object (File)
Sep 27 2024, 8:16 PM
Unknown Object (File)
Sep 6 2024, 3:06 AM
Unknown Object (File)
Sep 5 2024, 3:39 PM
Unknown Object (File)
Sep 4 2024, 10:41 PM
Unknown Object (File)
Sep 2 2024, 11:09 PM
Subscribers

Details

Summary

The standard is somewhat unclear, but on the balance, I believe that the
phrase “the rest of the input line” should be interpreted to mean the
rest of the input line including the terminating newline if and only if
there is one. This means the current implementation is incorrect on two
points:

  • First, it suppresses the previous line's newline in the '1' case.
  • Second, it unconditionally emits a newline at the end of the output for non-empty input, even if the input did not end with a newline.

Resolve this by rewriting the main loop. Instead of special-casing the
first line and then assuming that every line ends with a newline, we
remember how each line ends and emit that either at the beginning of
the next line or at the end of the file except in the one case ('+')
where the standard explicitly says not to.

While here, try to reduce diff to upstream a little and update their
RCS tag to reflect the fact that while we've diverged significantly
from them, we've incorporated all their changes. Remove the useless
second RCS tag.

We also update the tests to account for the change in interpretation
of the '1' case and add a test case for unterminated input.

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 55254
Build 52143: arc lint + arc unit

Event Timeline

des requested review of this revision.Jan 5 2024, 1:28 PM

reduce diff to upstream, update rcs tag

kevans added a subscriber: kevans.

This agrees with my reading of the spec, and feels more natural.

This revision is now accepted and ready to land.Jan 6 2024, 5:39 AM
This revision was automatically updated to reflect the committed changes.