On 01/22/2013 10:43 AM, Marcel Böhme wrote:

Dear all,

There is another bug that sneaked into the speed patch of seq on 13.09.12:

560   if (all_digits_p (argv[optind])
561       && (n_args == 1 || all_digits_p (argv[optind + 1]))
562       && (n_args < 3 || STREQ ("1", argv[optind + 2]))
563       && !equal_width && !format_str && strlen (separator) == 1)

That should probably be:
560   if (all_digits_p (argv[optind])
561       && (n_args == 1 || all_digits_p (argv[optind + 1]))
562       && (n_args < 3 || STREQ ("1", argv[optind + 1]))
563       && !equal_width && !format_str && strlen (separator) == 1)

Sigh we really messed up seq in that release :(
The attached should fix it:

I also notice another regression,
which I'll fix in a moment.

 $ seq 0 1 0
 0
 1

thanks,
Pádraig.
>From 8855d835bdfc69c111790d7aea91a78097640023 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <p...@draigbrady.com>
Date: Tue, 22 Jan 2013 11:13:16 +0000
Subject: [PATCH] seq: fix to always honor the step value
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* src/seq.c (main): With 3 positive integer args we were
checking the end value was == "1", rather than the step value.
* tests/misc/seq.pl: Add a test foro this case.
Reported by Marcel Böhme in http://bugs.gnu.org/13525
---
 NEWS              |    3 ++-
 src/seq.c         |    2 +-
 tests/misc/seq.pl |    4 ++++
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index 46d1aba..5b1a5f1 100644
--- a/NEWS
+++ b/NEWS
@@ -49,7 +49,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
   seq -s no longer prints an erroneous newline after the first number, and
   outputs a newline after the last number rather than a trailing separator.
-  [bug introduced in coreutils-8.20]
+  Also seq no longer ignores a specified step value.
+  [bugs introduced in coreutils-8.20]
 
 ** Changes in behavior
 
diff --git a/src/seq.c b/src/seq.c
index e1b467c..7ac94b9 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -559,7 +559,7 @@ main (int argc, char **argv)
      then use the much more efficient integer-only code.  */
   if (all_digits_p (argv[optind])
       && (n_args == 1 || all_digits_p (argv[optind + 1]))
-      && (n_args < 3 || STREQ ("1", argv[optind + 2]))
+      && (n_args < 3 || STREQ ("1", argv[optind + 1]))
       && !equal_width && !format_str && strlen (separator) == 1)
     {
       char const *s1 = n_args == 1 ? "1" : argv[optind];
diff --git a/tests/misc/seq.pl b/tests/misc/seq.pl
index 40a7571..93a71bd 100755
--- a/tests/misc/seq.pl
+++ b/tests/misc/seq.pl
@@ -133,6 +133,10 @@ my @Tests =
    ['sep-1', qw(-s, 1 3), {OUT => [qw(1,2,3)]}],
    ['sep-2', qw(-s, 1 1), {OUT => [qw(1)]}],
    ['sep-3', qw(-s,, 1 3), {OUT => [qw(1,,2,,3)]}],
+
+   # Exercise a step value != 1, with positive integer start and end,
+   # which was broken in 8.20
+   ['step-1', qw(1 3 1), {OUT => [qw(1)]}],
   );
 
 # Append a newline to each entry in the OUT array.
-- 
1.7.6.4

Reply via email to