summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2007-11-17 10:04:07 +0100
committerJim Meyering <meyering@redhat.com>2007-11-17 10:04:07 +0100
commit93914c7b1262cff6e933cb66c8392d81e168b196 (patch)
treebbb64023ce185c59cce51dcd549f5305cf80865a
parenta03811f5196aec86fd8eb682bd55bdff266f1451 (diff)
downloadcoreutils-93914c7b1262cff6e933cb66c8392d81e168b196.tar.xz
Correct preceding patch.
* src/seq.c (print_numbers): Also handle first < last && step < 0. * tests/misc/seq [empty-rev]: New test for this case.
-rw-r--r--ChangeLog4
-rw-r--r--src/seq.c2
-rwxr-xr-xtests/misc/seq1
3 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d563ae900..6e6f713b2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2007-11-17 Jim Meyering <meyering@redhat.com>
+ Correct preceding patch.
+ * src/seq.c (print_numbers): Also handle first < last && step < 0.
+ * tests/misc/seq [empty-rev]: New test for this case.
+
"seq .1 .1" would mistakenly generate no output on some systems
* NEWS: Say this.
* src/seq.c (print_numbers): Handle another floating point corner case.
diff --git a/src/seq.c b/src/seq.c
index 77d558697..eec5ed554 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -285,7 +285,7 @@ print_numbers (char const *fmt, struct layout layout,
Hence the first conjunct: don't break out of this loop when
i == 0. *unless* first and last themselves are out of order,
in which case we must print nothing, e.g. for ./seq -1 */
- if (i || last < first)
+ if (i || (0 < step && last < first) || (step < 0 && first < last))
break;
}
diff --git a/tests/misc/seq b/tests/misc/seq
index 17c8f0c6c..3365d9521 100755
--- a/tests/misc/seq
+++ b/tests/misc/seq
@@ -42,6 +42,7 @@ my @Tests =
(
['onearg-1', qw(10), {OUT => [(1..10)]}],
['onearg-2', qw(-1)],
+ ['empty-rev', qw(1 -1 3)],
['neg-1', qw(-10 10 10), {OUT => [qw(-10 0 10)]}],
# ['neg-2', qw(-.1 .1 .11), {OUT => [qw(-0.1 0.0 0.1)]}],
['neg-3', qw(1 -1 0), {OUT => [qw(1 0)]}],