diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2016-04-14 12:39:28 +0200 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2016-04-14 12:39:28 +0200 |
commit | 9a2e8ac489d7f7b2af4e1468f6174db9106eb9e4 (patch) | |
tree | 321ec73641cd24d324fbb22f297cd042742e125b /tests | |
parent | 81e589021d9c47e4fbc4284e82881a9703246476 (diff) | |
download | coreutils-9a2e8ac489d7f7b2af4e1468f6174db9106eb9e4.tar.xz |
seq: do not allow NaN arguments
* src/seq.c (isnan): Define macro.
(scan_arg): Add check if the given argument is NaN, and exit with
a proper error diagnostic in such a case.
(usage): Document it.
* tests/misc/seq.pl: Add tests.
* doc/coreutils.texi (seq invocation): Document the change.
* NEWS (Changes in behavior): Mention the change.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/seq.pl | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/misc/seq.pl b/tests/misc/seq.pl index ac0664fc6..130bbf3d7 100755 --- a/tests/misc/seq.pl +++ b/tests/misc/seq.pl @@ -26,6 +26,7 @@ use strict; my $prog = 'seq'; my $try_help = "Try '$prog --help' for more information.\n"; my $err_inc_zero = "seq: invalid Zero increment value: '0'\n".$try_help; +my $err_nan_arg = "seq: invalid 'not-a-number' argument: 'nan'\n".$try_help; my $locale = $ENV{LOCALE_FR_UTF8}; ! defined $locale || $locale eq 'none' @@ -161,6 +162,22 @@ my @Tests = {ERR_SUBST => 's/0.0/0/'}], ['inc-zero-4', qw(1 -0.0e-10 10), {EXIT => 1},{ERR => $err_inc_zero}, {ERR_SUBST => 's/-0\.0e-10/0/'}], + + # Ensure NaN arguments rejected. + ['nan-first-1', qw(nan), {EXIT => 1}, {ERR => $err_nan_arg}], + ['nan-first-2', qw(NaN 2), {EXIT => 1}, {ERR => $err_nan_arg}, + {ERR_SUBST => 's/NaN/nan/'}], + ['nan-first-3', qw(nan 1 2), {EXIT => 1}, {ERR => $err_nan_arg}], + ['nan-first-4', qw(-- -nan), {EXIT => 1}, {ERR => $err_nan_arg}, + {ERR_SUBST => 's/-nan/nan/'}], + ['nan-inc-1', qw(1 nan 2), {EXIT => 1}, {ERR => $err_nan_arg}], + ['nan-inc-2', qw(1 -NaN 2), {EXIT => 1}, {ERR => $err_nan_arg}, + {ERR_SUBST => 's/-NaN/nan/'}], + ['nan-last-1', qw(1 1 nan), {EXIT => 1}, {ERR => $err_nan_arg}], + ['nan-last-2', qw(1 NaN), {EXIT => 1}, {ERR => $err_nan_arg}, + {ERR_SUBST => 's/NaN/nan/'}], + ['nan-last-3', qw(0 -1 -NaN), {EXIT => 1}, {ERR => $err_nan_arg}, + {ERR_SUBST => 's/-NaN/nan/'}], ); # Append a newline to each entry in the OUT array. |