summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2013-01-22 11:13:16 +0000
committerPádraig Brady <P@draigBrady.com>2013-01-26 02:37:13 +0000
commit2238ab574191d30b89a007b760c616efaf9c219c (patch)
tree289b6fe06491cb9c30ceac15d607985c07d0981c /src
parent326e5855bc8dd3d0c5b2c0e461c65879d2b5694d (diff)
downloadcoreutils-2238ab574191d30b89a007b760c616efaf9c219c.tar.xz
seq: fix to always honor the step value
* 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 tests for this case. Reported by Marcel Böhme in http://bugs.gnu.org/13525
Diffstat (limited to 'src')
-rw-r--r--src/seq.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/seq.c b/src/seq.c
index 5ad5fad94..acbe2350a 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -565,11 +565,12 @@ 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])
+ && all_digits_p (argv[optind + 2])))
&& !equal_width && !format_str && strlen (separator) == 1)
{
char const *s1 = n_args == 1 ? "1" : argv[optind];
- char const *s2 = n_args == 1 ? argv[optind] : argv[optind + 1];
+ char const *s2 = argv[optind + (n_args - 1)];
if (seq_fast (s1, s2))
exit (EXIT_SUCCESS);