mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-19 03:33:43 +03:00
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.
This commit is contained in:
1 parent
3cd48057c7
commit
3fe8bc09be
13 files changed
+166
-27
No files matched your search
+2
-2
@@ -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;
|
||||
|
||||
+2
-2
@@ -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. */
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+3
-3
@@ -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. */
|
||||
|
||||
Reference in new issue
Block a user