diff options
author | Jim Meyering <jim@meyering.net> | 2003-11-29 11:55:52 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2003-11-29 11:55:52 +0000 |
commit | b91ac83e675ed779664fbe7fe8f0062a953aaf19 (patch) | |
tree | 791efc80201eb288a459a1673572914bd14427d3 /lib/c-strtod.c | |
parent | a9c4ddaaa895a3b7079bca52027ca8b79fce6e43 (diff) | |
download | coreutils-b91ac83e675ed779664fbe7fe8f0062a953aaf19.tar.xz |
(c_strtod): Save and restore original LC_NUMERIC setting,
in case it was different from the environment-derived value.
Patch by Paul Eggert.
Diffstat (limited to 'lib/c-strtod.c')
-rw-r--r-- | lib/c-strtod.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/c-strtod.c b/lib/c-strtod.c index b3fac020a..b3ce2b43a 100644 --- a/lib/c-strtod.c +++ b/lib/c-strtod.c @@ -27,8 +27,21 @@ double c_strtod (char const *nptr, char **endptr) { double r; - setlocale (LC_NUMERIC, "C"); + char *saved_locale = setlocale (LC_NUMERIC, NULL); + + if (saved_locale) + { + saved_locale = xstrdup (saved_locale); + setlocale (LC_NUMERIC, "C"); + } + r = strtod (nptr, endptr); - setlocale (LC_NUMERIC, ""); + + if (saved_locale) + { + setlocale (LC_NUMERIC, saved_locale); + free (saved_locale); + } + return r; } |