about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-03-11 17:29:47 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-03-11 17:29:47 +0000
commitc7564985e53e81de8ab70399b12c1258f45ac303 (patch)
tree8fd9c63d7d7fe419895abd973d730e127f7eb93b
parent1d80cc9acf21080119a9c2704ca2a15aa09d1659 (diff)
downloadzsh-c7564985e53e81de8ab70399b12c1258f45ac303.tar.gz
zsh-c7564985e53e81de8ab70399b12c1258f45ac303.tar.xz
zsh-c7564985e53e81de8ab70399b12c1258f45ac303.zip
18337: use C locale when converting floats to scalars to avoid problems in
locales where `,' is the decimal separator
-rw-r--r--ChangeLog8
-rw-r--r--Src/params.c13
2 files changed, 19 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 698492e1e..9078c91eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-03-11  Oliver Kiddle  <opk@zsh.org>
+
+	* 18338: Completion/Base/Widget/_next_tags: list a single
+	unambiguous match instead of inserting it
+
+	* 18337: Src/params.c: use C locale when converting floats to scalars
+	to avoid problems in locales where `,' is the decimal separator
+
 2003-03-10  Oliver Kiddle  <opk@zsh.org>
 
 	* 18330: Src/math.c: save output of setlocale as the pointer it
diff --git a/Src/params.c b/Src/params.c
index dce65a590..29f6e4072 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3417,6 +3417,7 @@ char *
 convfloat(double dval, int digits, int flags, FILE *fout)
 {
     char fmt[] = "%.*e";
+    char *prev_locale, *ret;
 
     /*
      * The difficulty with the buffer size is that a %f conversion
@@ -3451,16 +3452,24 @@ convfloat(double dval, int digits, int flags, FILE *fout)
 	    digits--;
 	}
     }
+#ifdef USE_LOCALE
+    prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));
+    setlocale(LC_NUMERIC, "POSIX");
+#endif
     if (fout) {
 	fprintf(fout, fmt, digits, dval);
-	return NULL;
+	ret = NULL;
     } else {
 	VARARR(char, buf, 512 + digits);
 	sprintf(buf, fmt, digits, dval);
 	if (!strchr(buf, 'e') && !strchr(buf, '.'))
 	    strcat(buf, ".");
-	return dupstring(buf);
+	ret = dupstring(buf);
     }
+#ifdef USE_LOCALE
+    if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
+#endif
+    return ret;
 }
 
 /* Start a parameter scope */