chiark / gitweb /
util: rework safe_atod() to be locale-independent
[elogind.git] / src / shared / util.c
index a6ec79a29222042be9467d2cbc3410c71899a8a8..38ee493a814a4e84f4a930557e6e8271745ba855 100644 (file)
@@ -372,8 +372,10 @@ int safe_atod(const char *s, double *ret_d) {
         assert(s);
         assert(ret_d);
 
-        errno = 0;
-        d = strtod(s, &x);
+        RUN_WITH_LOCALE(LC_NUMERIC_MASK, "C") {
+                errno = 0;
+                d = strtod(s, &x);
+        }
 
         if (!x || x == s || *x || errno)
                 return errno ? -errno : -EINVAL;