From b91ac83e675ed779664fbe7fe8f0062a953aaf19 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 29 Nov 2003 11:55:52 +0000 Subject: (c_strtod): Save and restore original LC_NUMERIC setting, in case it was different from the environment-derived value. Patch by Paul Eggert. --- lib/c-strtod.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'lib') 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; } -- cgit v1.2.3-54-g00ecf