We should save the current locale, use the 'C' locale during parsing,
then restore the original locale. Config files should always parse
regardless of the current user's locale setting. Fixes FS#34253.
Signed-off-by: Dan McGee
---
src/pacman/conf.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 815df95..3f1b1c3 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -21,6 +21,7 @@
#include
#include
#include
+#include /* setlocale */
#include /* open */
#include
#include
@@ -514,7 +515,15 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "UseDelta") == 0) {
double ratio;
char *endptr;
+ const char *oldlocale;
+
+ /* set the locale to 'C' for consistant decimal parsing (0.7 and never
+ * 0,7) from config files, then restore old setting when we are done */
+ oldlocale = setlocale(LC_NUMERIC, NULL);
+ setlocale(LC_NUMERIC, "C");
ratio = strtod(value, &endptr);
+ setlocale(LC_NUMERIC, oldlocale);
+
if(*endptr != '\0' || ratio < 0.0 || ratio > 2.0) {
pm_printf(ALPM_LOG_ERROR,
_("config file %s, line %d: invalid value for '%s' : '%s'\n"),
--
1.8.1.5