bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new snapshot available: coreutils-6.12.208-2441


From: Jim Meyering
Subject: Re: new snapshot available: coreutils-6.12.208-2441
Date: Sun, 28 Sep 2008 13:35:52 +0200

Eric Blake <address@hidden> wrote:
> According to Eric Blake on 9/27/2008 6:34 PM:
>> This needs fixing (hmm, gnulib doesn't yet have a strtold module;
>> time to start factoring strtod to long double):
>
> Or maybe we go with this lighter-weight patch, which matches the
> inaccuracies already present in c-strtold?  (ie. without a strtold module,
> this is not a regression, since c-strtold did the same hack)

On that front, rather than my change from c_strtold to strtold, I would
have preferred to use a version of asprintf (c_asprintf?) that would
act as if it were in the C locale, since there is no implicit need for
a locale-aware conversion in this internal process.

Now that I think about it...
Since seq.c is an application (as opposed to library), there's no harm
in changing the locale and then changing it back, so now I'm leaning
towards using the patch below.

What do you think?


diff --git a/src/seq.c b/src/seq.c
index b5f0651..b41aab6 100644
--- a/src/seq.c
+++ b/src/seq.c
@@ -301,12 +301,15 @@ print_numbers (char const *fmt, struct layout layout,
              bool print_extra_number = false;
              long double x_val;
              char *x_str;
-             int x_strlen = asprintf (&x_str, fmt, x);
+             int x_strlen;
+             setlocale (LC_NUMERIC, "C");
+             x_strlen = asprintf (&x_str, fmt, x);
+             setlocale (LC_NUMERIC, "");
              if (x_strlen < 0)
                xalloc_die ();
              x_str[x_strlen - layout.suffix_len] = '\0';

-             if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, strtold)
+             if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, c_strtold)
                  && abs_rel_diff (x_val, last) < DBL_EPSILON)
                {
                  char *x0_str = NULL;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]