]> git.ipfire.org Git - thirdparty/coreutils.git/commit
seq: fix superfluous output line
authorAssaf Gordon <assafgordon@gmail.com>
Thu, 1 Aug 2019 23:01:21 +0000 (17:01 -0600)
committerAssaf Gordon <assafgordon@gmail.com>
Sat, 3 Aug 2019 00:29:25 +0000 (18:29 -0600)
commit07f811a3c02d3d6dc1943030afccdfdcf7ac1e5e
tree3e7dcff377553d23a10c5917c994b4b4e66e835f
parentc0f2219d3a95fb535ccd6cbe1d18cb5c38ce4acb
seq: fix superfluous output line

Under certain circumstances seq prints an extra line when the output
format has custom format with characters following the printed numbers:

    $ seq -f "%g " 1000000 1000000
     1e+06
     1e+06

This is due to the "print_extra_number" logic using strings to determine
whether a 'extra number' is needed, but only one string was trimmed
when using a custom printf format.

Prompted by https://lists.gnu.org/r/coreutils/2019-08/msg00001.html

* NEWS: Mention fix.
* src/seq.c (print_numbers): Trim the 'x0_str' string before comparing
it to the previous 'x_str' string.
* tests/misc/seq-extra-number.sh: Add this scenario.
* tests/local.mk (all_tests): Add new test.
NEWS
src/seq.c
tests/local.mk
tests/misc/seq-extra-number.sh [new file with mode: 0755]