seq: solve e13188e7ef7bbd609c1586332a335b4194b881aa more cleanly
authorJim Meyering <meyering@redhat.com>
Sun, 28 Sep 2008 12:18:59 +0000 (14:18 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 29 Sep 2008 13:28:03 +0000 (15:28 +0200)
* src/seq.c (print_numbers): Don't switch c_strtold -> strtold
in order to accommodate the locale-dependent behavior of our internal
asprintf use.  Instead, simply set the locale to C before calling
asprintf, and then set it back afterwards.

src/seq.c

index b5f0651..b41aab6 100644 (file)
--- 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;