[pacman-dev] [PATCH] Use C locale for parsing Delta value

Allan McRae allan at archlinux.org
Sun Mar 10 23:40:07 EDT 2013


Locales that use "," as their decimal separator resulted in parsing
issues with the Delta value. Ensure the C locale is used during parsing.

Fixes FS#34253

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 src/pacman/conf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 815df95..71bfed6 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -22,6 +22,7 @@
 #include <glob.h>
 #include <limits.h>
 #include <fcntl.h> /* open */
+#include <locale.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h> /* strdup */
@@ -514,7 +515,9 @@ static int _parse_options(const char *key, char *value,
 		} else if(strcmp(key, "UseDelta") == 0) {
 			double ratio;
 			char *endptr;
+			setlocale(LC_NUMERIC, "C");
 			ratio = strtod(value, &endptr);
+			setlocale(LC_NUMERIC, "");
 			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



More information about the pacman-dev mailing list