Fix a bug where lines of the input file were not correctly distributed
to the columns of the output page if there were fewer lines than the
total number of cells in the output table. For example, before this
commit,
printf "a\nb\n" | pr -2
would incorrectly produce an output page like this:
a
b
After this commit, it produces a more correct output page like this:
a b
Fix a bug in `pr` where a form feed character (`\f`) immediately
following a newline character (`\n`) was incorrectly rendered as an
extra blank line in the output when running with the `-f` option. After
this commit, the empty line is correctly ignored.
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
Fix a bug in `pr` where a newline character (`\n`) immediately following
a form feed character (`\f`) was incorrectly rendered as an extra blank
line in the output. After this commit, the newline is correctly ignored.
Fix the way form feed characters are interpreted by changing the way
lines and pages are found. Before this commit, a file comprising two
form feed characters (`/f/f`) would result in too few trailing newlines
at the end of the second page. After this change, each page is produced
with the correct number of lines.
This commit changes the way files are read, replacing complex iterators
with a loop-based approach, iteratively scanning for newline or form
feed characters. The `memchr` library is used to efficiently scan for
these two characters. One downside of this implementation is that it
currently reads the entire input file into memory; this can be improved
in subsequent merge requests.
Remove unit test for `pr` that was enforcing incorrect behavior. These
tests were ostensibly designed to match corresponding ones in the GNU
test suite, but they don't match the current behavior of GNU `pr`, so it
is not valuable to keep them.
Set the default line width to 72 for all page headers in `pr`,
regardless of whether a custom date format is being used. Before, a
single space was used to separate the three components of the header
(date, filename, and page number) if a custom date format was not given.