]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
seq: fix incorrect output with start or end of -0
authorPádraig Brady <P@draigBrady.com>
Wed, 18 Jun 2014 13:30:57 +0000 (14:30 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 18 Jun 2014 17:05:02 +0000 (18:05 +0100)
* src/seq.c (main): Avoid seq_fast() with a start or end of -0.
* tests/misc/seq.pl: Add test cases.
* NEWS: Mention the fix.
Fixes http://bugs.gnu.org/17800

NEWS
src/seq.c
tests/misc/seq.pl

diff --git a/NEWS b/NEWS
index 5d1fe99406b8cfc4e7212bf4187cebeee2ed6eb0..77286f884e244abb5fb5e2a8f1fb326ebd92d91f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   ptx now consistently trims whitespace when processing multiple files.
   [This bug was present in "the beginning".]
 
+  seq again generates correct output with start or end values = -0.
+  [bug introduced in coreutils-8.20.]
+
   shuf --repeat no longer dumps core if the input is empty.
   [bug introduced with the --repeat feature in coreutils-8.22]
 
index 8fced4a0e7374fa4fc07e2236642d7966edb86d5..1124358cf14562b633ff550127207a3e08ece09d 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -604,7 +604,7 @@ main (int argc, char **argv)
       if (asprintf (&s2, "%0.Lf", last.value) < 0)
         xalloc_die ();
 
-      if (seq_fast (s1, s2))
+      if (*s1 != '-' && *s2 != '-' && seq_fast (s1, s2))
         {
           IF_LINT (free (s1));
           IF_LINT (free (s2));
index 329e1dfb2d67bde53df69896a82f46622f21d3f9..924843637b712d3a4810329279fb7a137673fac7 100755 (executable)
@@ -143,6 +143,9 @@ my @Tests =
    ['not-fast-1', qw(1 3 1), {OUT => [qw(1)]}],
    ['not-fast-2', qw(1 1 4.2), {OUT => [qw(1 2 3 4)]}],
    ['not-fast-3', qw(1 1 0)],
+   # In 8.20..8.22 a start or end of -0 was broken
+   ['not-fast-4', qw(-0 10), {OUT => [qw(-0 1 2 3 4 5 6 7 8 9 10)]}],
+   ['not-fast-5', qw(1 -0)],
 
    # Ensure the correct parameters are passed to the fast path
    ['fast-1', qw(4), {OUT => [qw(1 2 3 4)]}],