improve POSIX compliance by continuing to process the remaining file
operands after not finding an input file.
from the IEEE Std 1003.1-2008 (``POSIX.1'') rationale:
"Unlike other utilities, some historical implementations of cut
exit after not finding an input file, rather than continuing to
process the remaining file operands. This behavior is prohibited
by this volume of POSIX.1-2008, where only the exit status is
affected by this problem."
joint work with jmc@, who identified the compliance issue, and millert@
ok millert@, jmc@
using the patch from the PR and some hacking by myself to avoid code
redundancy.
Passes the regression tests I've added.
(How many weeks of purgatory do I get for the cpp(1) hack to avoid
code redundancy? I guess I can always say it was inspired by some old
version of our md5 sources...)
buffer inside the loop. Fixes coverty CID:1674.
(This should only happen at EOF, so the loop SHOULD terminate.)
While here always output a newline at the end of the input data even when
the last (unterminated) line doesn't contain a separator.
XXX is it better to output a newline?
> revision 1.7
> date: 2000/06/04 23:52:19; author: aaron; state: Exp; lines: +30 -14
> Handle the case where the last line of input does not contain a newline; issue
> reported by marc@snafu.org. The main thing here is we use fgetln() instead of
> fgets(), also giving us the advantage of being able to handle lines of
> unlimited length. Some -Wall and other fixes from millert@ as well.