diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-26 16:37:01 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2019-01-26 22:41:09 -0800 |
commit | 3fe8bc09be53d9160073abf09d8ec0fa39740fa6 (patch) | |
tree | b148bc2963d034d5ebc8ebe93e613ffe72bc992f /src | |
parent | 3cd48057c70f7e733e6b39e0ab3bb43c4e2d1c13 (diff) | |
download | coreutils-3fe8bc09be53d9160073abf09d8ec0fa39740fa6.tar.gz |
printf,seq,sleep,tail,timeout: accept current-locale floats
These commands now accept floating-point numbers in the
current locale, as well as in the C locale.
Compatibility problem reported by Robert Elz.
* NEWS: Document this.
* bootstrap.conf (gnulib_modules): Add cl-strtod, cl-strtold.
Remove c-strtold.
* doc/coreutils.texi (Floating point, tail invocation)
(printf invocation, timeout invocation, sleep invocation)
(seq invocation): Document this.
* gl/lib/cl-strtod.c, gl/lib/cl-strtod.h, gl/lib/cl-strtold.c:
* gl/modules/cl-strtod, gl/modules/cl-strtold: New files.
* src/printf.c, src/seq.c, src/sleep.c, src/tail.c, src/timeout.c:
Include cl-strtod.h instead of c-strtod.
* src/printf.c (vstrtold):
* src/seq.c (scan_arg, print_numbers):
* src/sleep.c (main):
* src/tail.c (parse_options):
* src/timeout.c (parse_duration):
Use cl_strtold instead of c_strtold.
Diffstat (limited to 'src')
-rw-r--r-- | src/printf.c | 4 | ||||
-rw-r--r-- | src/seq.c | 6 | ||||
-rw-r--r-- | src/sleep.c | 4 | ||||
-rw-r--r-- | src/tail.c | 4 | ||||
-rw-r--r-- | src/timeout.c | 6 |
5 files changed, 12 insertions, 12 deletions
diff --git a/src/printf.c b/src/printf.c index 28e058f50..3260868cb 100644 --- a/src/printf.c +++ b/src/printf.c @@ -55,7 +55,7 @@ #include <sys/types.h> #include "system.h" -#include "c-strtod.h" +#include "cl-strtod.h" #include "die.h" #include "error.h" #include "quote.h" @@ -188,7 +188,7 @@ FUNC_NAME (char const *s) \ STRTOX (intmax_t, vstrtoimax, strtoimax (s, &end, 0)) STRTOX (uintmax_t, vstrtoumax, strtoumax (s, &end, 0)) -STRTOX (long double, vstrtold, c_strtold (s, &end)) +STRTOX (long double, vstrtold, cl_strtold (s, &end)) /* Output a single-character \ escape. */ @@ -23,7 +23,7 @@ #include "system.h" #include "die.h" -#include "c-strtod.h" +#include "cl-strtod.h" #include "error.h" #include "quote.h" #include "xstrtod.h" @@ -142,7 +142,7 @@ scan_arg (const char *arg) { operand ret; - if (! xstrtold (arg, NULL, &ret.value, c_strtold)) + if (! xstrtold (arg, NULL, &ret.value, cl_strtold)) { error (0, 0, _("invalid floating point argument: %s"), quote (arg)); usage (EXIT_FAILURE); @@ -331,7 +331,7 @@ print_numbers (char const *fmt, struct layout layout, xalloc_die (); x_str[x_strlen - layout.suffix_len] = '\0'; - if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold) + if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, cl_strtold) && x_val == last) { char *x0_str = NULL; diff --git a/src/sleep.c b/src/sleep.c index 23a941636..a634f1ae6 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -20,7 +20,7 @@ #include <getopt.h> #include "system.h" -#include "c-strtod.h" +#include "cl-strtod.h" #include "die.h" #include "error.h" #include "long-options.h" @@ -128,7 +128,7 @@ main (int argc, char **argv) { double s; const char *p; - if (! (xstrtod (argv[i], &p, &s, c_strtod) || errno == ERANGE) + if (! (xstrtod (argv[i], &p, &s, cl_strtod) || errno == ERANGE) /* Nonnegative interval. */ || ! (0 <= s) /* No extra chars after the number and an optional s,m,h,d char. */ diff --git a/src/tail.c b/src/tail.c index b8064853f..dee827bc8 100644 --- a/src/tail.c +++ b/src/tail.c @@ -36,7 +36,7 @@ #include "system.h" #include "argmatch.h" -#include "c-strtod.h" +#include "cl-strtod.h" #include "die.h" #include "error.h" #include "fcntl--.h" @@ -2244,7 +2244,7 @@ parse_options (int argc, char **argv, case 's': { double s; - if (! (xstrtod (optarg, NULL, &s, c_strtod) && 0 <= s)) + if (! (xstrtod (optarg, NULL, &s, cl_strtod) && 0 <= s)) die (EXIT_FAILURE, 0, _("invalid number of seconds: %s"), quote (optarg)); *sleep_interval = s; diff --git a/src/timeout.c b/src/timeout.c index 560af1a7c..748832f8a 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -55,7 +55,7 @@ #include <sys/wait.h> #include "system.h" -#include "c-strtod.h" +#include "cl-strtod.h" #include "xstrtod.h" #include "sig2str.h" #include "operand2sig.h" @@ -316,12 +316,12 @@ apply_time_suffix (double *x, char suffix_char) } static double -parse_duration (const char* str) +parse_duration (const char *str) { double duration; const char *ep; - if (! (xstrtod (str, &ep, &duration, c_strtod) || errno == ERANGE) + if (! (xstrtod (str, &ep, &duration, cl_strtod) || errno == ERANGE) /* Nonnegative interval. */ || ! (0 <= duration) /* No extra chars after the number and an optional s,m,h,d char. */ |