mirror of
https://gitlab.freedesktop.org/upower/upower.git
synced 2026-05-05 06:28:00 +02:00
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:
parent
498d4491ed
commit
cf5d24922e
1 changed files with 2 additions and 2 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue