From cf5d24922ed3634af8a7a3def998c14600f8dff3 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sun, 20 Oct 2013 13:31:21 +0200 Subject: 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. --- src/linux/sysfs-utils.c | 4 ++-- 1 file 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); -- cgit v1.2.1