about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorOliver Kiddle <opk@users.sourceforge.net>2003-05-12 14:03:26 +0000
committerOliver Kiddle <opk@users.sourceforge.net>2003-05-12 14:03:26 +0000
commit453df705675869123675ba399f08e92ca658aa2f (patch)
tree798f662aa7409f830c84f4bc8897d92f88fe57a6 /Src
parentfa09beea011a6d5727f917d84dd55bd9f86e5f28 (diff)
downloadzsh-453df705675869123675ba399f08e92ca658aa2f.tar.gz
zsh-453df705675869123675ba399f08e92ca658aa2f.tar.xz
zsh-453df705675869123675ba399f08e92ca658aa2f.zip
merge changes from 4.1
Diffstat (limited to 'Src')
-rw-r--r--Src/math.c4
-rw-r--r--Src/params.c16
2 files changed, 16 insertions, 4 deletions
diff --git a/Src/math.c b/Src/math.c
index 6e3fce777..2bf65d117 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -398,12 +398,12 @@ zzlex(void)
 		    /* it's a float */
 		    yyval.type = MN_FLOAT;
 #ifdef USE_LOCALE
-		    prev_locale = setlocale(LC_NUMERIC, NULL);
+		    prev_locale = dupstring(setlocale(LC_NUMERIC, NULL));
 		    setlocale(LC_NUMERIC, "POSIX");
 #endif
 		    yyval.u.d = strtod(ptr, &nptr);
 #ifdef USE_LOCALE
-		    setlocale(LC_NUMERIC, prev_locale);
+		    if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
 #endif
 		    if (ptr == nptr || *nptr == '.') {
 			zerr("bad floating point constant", NULL, 0);
diff --git a/Src/params.c b/Src/params.c
index f461c15e0..255260467 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -3213,6 +3213,10 @@ char *
 convfloat(double dval, int digits, int flags, FILE *fout)
 {
     char fmt[] = "%.*e";
+    char *ret;
+#ifdef USE_LOCALE
+    char *prev_locale;
+#endif 
 
     /*
      * The difficulty with the buffer size is that a %f conversion
@@ -3247,14 +3251,22 @@ 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);
-	return dupstring(buf);
+	ret = dupstring(buf);
     }
+#ifdef USE_LOCALE
+    if (prev_locale) setlocale(LC_NUMERIC, prev_locale);
+#endif
+    return ret;
 }
 
 /* Start a parameter scope */