mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-04-12 15:06:44 +02:00
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
This commit is contained in:
3
NEWS
3
NEWS
@@ -57,7 +57,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 when the end value is 1.
|
||||
[bugs introduced in coreutils-8.20]
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -137,6 +137,17 @@ 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 fast path avoidance logic.
|
||||
# In 8.20 a step value != 1, with positive integer start and end was broken
|
||||
['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)],
|
||||
|
||||
# Ensure the correct parameters are passed to the fast path
|
||||
['fast-1', qw(4), {OUT => [qw(1 2 3 4)]}],
|
||||
['fast-2', qw(1 4), {OUT => [qw(1 2 3 4)]}],
|
||||
['fast-3', qw(1 1 4), {OUT => [qw(1 2 3 4)]}],
|
||||
);
|
||||
|
||||
# Append a newline to each entry in the OUT array.
|
||||
|
||||
Reference in New Issue
Block a user