summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/seq.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/seq.c b/src/seq.c
index 91cf625e9..de92bc278 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -27,11 +27,14 @@
#include "quote.h"
#include "xstrtod.h"
-/* Roll our own isfinite rather than using <math.h>, so that we don't
+/* Roll our own isfinite/isnan rather than using <math.h>, so that we don't
have to worry about linking -lm just for isfinite. */
#ifndef isfinite
# define isfinite(x) ((x) * 0 == 0)
#endif
+#ifndef isnan
+# define isnan(x) ((x) != (x))
+#endif
/* The official name of this program (e.g., no 'g' prefix). */
#define PROGRAM_NAME "seq"
@@ -92,7 +95,7 @@ INCREMENT would become greater than LAST.\n\
FIRST, INCREMENT, and LAST are interpreted as floating point values.\n\
INCREMENT is usually positive if FIRST is smaller than LAST, and\n\
INCREMENT is usually negative if FIRST is greater than LAST.\n\
-INCREMENT must not be 0.\n\
+INCREMENT must not be 0; none of FIRST, INCREMENT and LAST may be NaN.\n\
"), stdout);
fputs (_("\
FORMAT must be suitable for printing one argument of type 'double';\n\
@@ -144,6 +147,13 @@ scan_arg (const char *arg)
usage (EXIT_FAILURE);
}
+ if (isnan (ret.value))
+ {
+ error (0, 0, _("invalid %s argument: %s"), quote_n (0, "not-a-number"),
+ quote_n (1, arg));
+ usage (EXIT_FAILURE);
+ }
+
/* We don't output spaces or '+' so don't include in width */
while (isspace (to_uchar (*arg)) || *arg == '+')
arg++;