summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/c-strtod.c17
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;
}