mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-02 07:15:39 +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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5169 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -3,6 +3,7 @@ lm-sensors CHANGES file
|
|||||||
|
|
||||||
SVN-HEAD
|
SVN-HEAD
|
||||||
libsensors: Use __func__ instead of __FUNCTION__
|
libsensors: Use __func__ instead of __FUNCTION__
|
||||||
|
Parse the configuration file in C locale
|
||||||
sensors-detect: Add SMSC SCH5027D detection
|
sensors-detect: Add SMSC SCH5027D detection
|
||||||
Do not access I/O ports on PPC
|
Do not access I/O ports on PPC
|
||||||
Move south bridge sensor detection to the right section
|
Move south bridge sensor detection to the right section
|
||||||
|
31
lib/init.c
31
lib/init.c
@@ -19,8 +19,10 @@
|
|||||||
MA 02110-1301 USA.
|
MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <locale.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "sensors.h"
|
#include "sensors.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
@@ -34,6 +36,31 @@
|
|||||||
#define DEFAULT_CONFIG_FILE ETCDIR "/sensors3.conf"
|
#define DEFAULT_CONFIG_FILE ETCDIR "/sensors3.conf"
|
||||||
#define ALT_CONFIG_FILE ETCDIR "/sensors.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 sensors_init(FILE *input)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@@ -47,7 +74,7 @@ int sensors_init(FILE *input)
|
|||||||
res = -SENSORS_ERR_PARSE;
|
res = -SENSORS_ERR_PARSE;
|
||||||
if (input) {
|
if (input) {
|
||||||
if (sensors_scanner_init(input) ||
|
if (sensors_scanner_init(input) ||
|
||||||
sensors_yyparse())
|
sensors_parse())
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
} else {
|
} else {
|
||||||
/* No configuration provided, use default */
|
/* No configuration provided, use default */
|
||||||
@@ -56,7 +83,7 @@ int sensors_init(FILE *input)
|
|||||||
input = fopen(ALT_CONFIG_FILE, "r");
|
input = fopen(ALT_CONFIG_FILE, "r");
|
||||||
if (input) {
|
if (input) {
|
||||||
if (sensors_scanner_init(input) ||
|
if (sensors_scanner_init(input) ||
|
||||||
sensors_yyparse()) {
|
sensors_parse()) {
|
||||||
fclose(input);
|
fclose(input);
|
||||||
goto exit_cleanup;
|
goto exit_cleanup;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user