diff --git a/CHANGES b/CHANGES index 04bdbe93..abdbed9d 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ lm_sensors CHANGES file SVN-HEAD Library: Don't choke on unrecognized devices, part 2 + Parse the configuration file in C locale (#2312) Module asb100: Remove some dead code (2.6 backport) Module i2c-amd756: Fix functionality flags (2.6 backport) Module i2c-amd756-s4882: Fix an error path (2.6 backport) diff --git a/lib/init.c b/lib/init.c index c7d9734c..2e7f696c 100644 --- a/lib/init.c +++ b/lib/init.c @@ -17,8 +17,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include +#include #include "sensors.h" #include "data.h" #include "proc.h" @@ -38,6 +40,31 @@ static void free_set(sensors_set set); static void free_compute(sensors_compute compute); static void free_ignore(sensors_ignore ignore); +/* Wrapper around sensors_yyparse(), which clears the locale so that + the decimal numbers are always parsed properly. */ +static int sensors_parse(void) +{ + int res; + char *locale; + + /* Remember the current locale and clear it */ + locale = setlocale(LC_ALL, NULL); + if (locale) { + locale = strdup(locale); + setlocale(LC_ALL, "C"); + } + + res = sensors_yyparse(); + + /* Restore the old locale */ + if (locale) { + setlocale(LC_ALL, locale); + free(locale); + } + + return res; +} + int sensors_init(FILE *input) { int res; @@ -51,7 +78,7 @@ int sensors_init(FILE *input) } if ((res = sensors_scanner_init(input))) return -SENSORS_ERR_PARSE; - if ((res = sensors_yyparse())) + if ((res = sensors_parse())) return -SENSORS_ERR_PARSE; if ((res = sensors_substitute_busses())) return res;