summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-04-25 00:04:02 -0300
committerLennart Poettering <lennart@poettering.net>2013-04-25 00:05:14 -0300
commitd6dd604b551987b411ec8930c23bd5c9c93ef864 (patch)
tree6599838f561b0621fda1bfb660bef74981607367 /src/shared/util.c
parentdb5c0122853a9ecf1cc92e6593461932df2fa866 (diff)
util: rework safe_atod() to be locale-independent
This adds some syntactic sugar with a macro RUN_WITH_LOCALE() that reset the thread-specific locale temporarily.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index a6ec79a292..38ee493a81 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -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;