diff options
author | Jim Meyering <meyering@redhat.com> | 2008-09-28 14:18:59 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2008-09-29 15:28:03 +0200 |
commit | cfe3602ad673f4873bd25d149861ee0c68f52f1b (patch) | |
tree | f5dba60ddf204dd463434f80abf8ae565c8e0593 /src | |
parent | cee53c14303b5c0a9c587242c775731e0a9c748e (diff) | |
download | coreutils-cfe3602ad673f4873bd25d149861ee0c68f52f1b.tar.xz |
seq: solve e13188e7ef7bbd609c1586332a335b4194b881aa more cleanly
* 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.
Diffstat (limited to 'src')
-rw-r--r-- | src/seq.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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; |