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.
This commit is contained in:
Bastien Nocera 2013-10-20 13:31:21 +02:00
parent 498d4491ed
commit cf5d24922e

View file

@ -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);