Skip to contentSkip to conversation

Use the current locale in sensors program

PATCH In review Aurelien Jarno 2 participants 2 messages Apr 6, 2008 – Apr 7, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use the current locale in sensors program

The previous patch fixed libsensors behaviour wrt locales, so I guess it is now safe to use the current locale for all categories in the sensors program. This includes LC_NUMERIC, so the values are printed using the correct decimal separator wrt to the locale settings.

Index: prog/sensors/main.c
=================================--- prog/sensors/main.c (révision 5168)
+++ prog/sensors/main.c (copie de travail)
@@ -257,7 +257,7 @@
{ 0, 0, 0, 0 }
};

- setlocale(LC_CTYPE, "");
+ setlocale(LC_ALL, "");

do_raw = 0;
do_sets = 0;

Signature · 9 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 11 lines · Aurelien Jarno

The previous patch fixed libsensors behaviour wrt locales, so I guess it is now safe to use the current locale for all categories in the sensors program. This includes LC_NUMERIC, so the values are printed using the correct decimal separator wrt to the locale settings.

Index: prog/sensors/main.c
=================================> --- prog/sensors/main.c (révision 5168)
+++ prog/sensors/main.c (copie de travail)

Review line 263

Quoted 8 lines
(quoted diff) +1 -1
@@ -257,7 +257,7 @@
 		{ 0, 0, 0, 0 }
 	};
 
-	setlocale(LC_CTYPE, "");
+	setlocale(LC_ALL, "");
 
 	do_raw = 0;
 	do_sets = 0;

I'm a bit reluctant to apply this. For one thing, it assumes that the libsensors locale fix is applied, while it should be possible to use sensors 3.0.1 with libsensors 3.0.2. This is unlikely to happen, but still.

For another, this will change the output of "sensors" and "sensors -u", which we know some people are parsing. While there is a workaround (have the caller change LC_ALL) this is still likely to break scripts out there.

Last but not least, sensors isn't internationalized, and I think it's a bit confusing to have sensors use English words (adapter, sensor, thermistor, alarm etc.) but write numbers using the French syntax.

I welcome other opinions on this patch though. If a clear majority think that this patch should be applied, my opinion on the matter isn't that strong.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors