mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-07 16:01:34 +00:00
The configuration file is currently parsed in the locale set by the main
program using the library. This means that if the decimal separator (defined in LC_NUMERIC) is not '.' the values in the compute lines are truncated. This happens for example with sensors-applet and a French locale. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=469333 Parsing the configuration file in C locale fixes the problem. Original patch from Aurelien Jarno. Also closes ticket #2312. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5286 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
38c7268590
commit
253dc9c9d9
2 files changed
+29
-1
No files matched your search
@@ -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)
|
||||
|
||||
+28
-1
@@ -17,8 +17,10 @@
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <locale.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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;
|
||||
|
||||
Reference in new issue
Block a user