diff --git a/CHANGES b/CHANGES index af3dab93..abb40df7 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,7 @@ lm-sensors CHANGES file SVN-HEAD libsensors: Use __func__ instead of __FUNCTION__ + Parse the configuration file in C locale sensors-detect: Add SMSC SCH5027D detection Do not access I/O ports on PPC Move south bridge sensor detection to the right section diff --git a/lib/init.c b/lib/init.c index 1c1f8834..d1ec201c 100644 --- a/lib/init.c +++ b/lib/init.c @@ -19,8 +19,10 @@ MA 02110-1301 USA. */ +#include #include #include +#include #include #include "sensors.h" #include "data.h" @@ -34,6 +36,31 @@ #define DEFAULT_CONFIG_FILE ETCDIR "/sensors3.conf" #define ALT_CONFIG_FILE ETCDIR "/sensors.conf" +/* 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; @@ -47,7 +74,7 @@ int sensors_init(FILE *input) res = -SENSORS_ERR_PARSE; if (input) { if (sensors_scanner_init(input) || - sensors_yyparse()) + sensors_parse()) goto exit_cleanup; } else { /* No configuration provided, use default */ @@ -56,7 +83,7 @@ int sensors_init(FILE *input) input = fopen(ALT_CONFIG_FILE, "r"); if (input) { if (sensors_scanner_init(input) || - sensors_yyparse()) { + sensors_parse()) { fclose(input); goto exit_cleanup; }