diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-10-20 13:31:21 +0200 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-10-20 13:51:21 +0200 |
commit | cf5d24922ed3634af8a7a3def998c14600f8dff3 (patch) | |
tree | e8b54088ea2357d748ff4b0a4a0d4a9b67990fd6 | |
parent | 498d4491edc154d41c1fc7659c263ed8128b4822 (diff) | |
download | upower-cf5d24922ed3634af8a7a3def998c14600f8dff3.tar.gz |
linux: Fix parsing of double values for certain locales
I don't think the kernel exports any numbers with a decimal
portion, but if they did, they would get the wrong values because
some locales use "," as the decimal separator, and not "." as the
kernel/C locale would.
-rw-r--r-- | src/linux/sysfs-utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/linux/sysfs-utils.c b/src/linux/sysfs-utils.c index 8cdff8d..a1b7891 100644 --- a/src/linux/sysfs-utils.c +++ b/src/linux/sysfs-utils.c @@ -52,7 +52,7 @@ sysfs_get_double_with_error (const char *dir, const char *attribute) filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { - result = atof (contents); + result = g_ascii_strtod (contents, NULL); g_free (contents); } else { result = -1.0; @@ -72,7 +72,7 @@ sysfs_get_double (const char *dir, const char *attribute) result = 0.0; filename = g_build_filename (dir, attribute, NULL); if (g_file_get_contents (filename, &contents, NULL, NULL)) { - result = atof (contents); + result = g_ascii_strtod (contents, NULL); g_free (contents); } g_free (filename); |