]> git.ipfire.org Git - thirdparty/coreutils.git/commit
nl: only fail if need to output overflowed numbers
authorPádraig Brady <P@draigBrady.com>
Sun, 25 Oct 2020 16:40:35 +0000 (16:40 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 25 Oct 2020 16:57:19 +0000 (16:57 +0000)
commitfe41d6c651eb0044e1d152b13f413874ba6bd731
tree20be8f83a955f79e9d05097bdae90db2d7a9cf93
parent175c7c6a60c562e1972199ae980a1bcd7027105e
nl: only fail if need to output overflowed numbers

Previously we would have failed immediately upon internal overflow,
which didn't output the full line being processed, and assumed
there would be another numbered line.

* src/nl.c (line_no_overflow): A new global to track overflow.
(print_lineno): Only fail if about to output an overflowed number.
(reset_lineno): A new function to refactor resetting of the number,
and which also clears line_no_overflow.
* tests/misc/nl.sh: Add a test case.
src/nl.c
tests/misc/nl.sh