about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-21 00:18:08 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-21 00:18:08 +0000
commit5d2f6534686ade26ae839339ff0e8436967aa156 (patch)
treec343b8750d4ed7332488a1c05dbbd432acc15345
parentd518d6ebdac838a36d7fa9616df6f07300a67dc4 (diff)
downloadzsh-5d2f6534686ade26ae839339ff0e8436967aa156.tar.gz
zsh-5d2f6534686ade26ae839339ff0e8436967aa156.tar.xz
zsh-5d2f6534686ade26ae839339ff0e8436967aa156.zip
zsh-workers/8693
-rw-r--r--Src/math.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/Src/math.c b/Src/math.c
index a2c123da4..7e4230c9b 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -184,20 +184,12 @@ static int type[TOKCOUNT] =
 static int
 zzlex(void)
 {
-    char decimal = '.', thousands = ',';
-    int cct = 0;
 #ifdef USE_LOCALE
-    struct lconv *lc;
+    char *prev_locale;
 #endif
-
+    int cct = 0;
     yyval.type = MN_INTEGER;
 
-#ifdef USE_LOCALE
-    lc = localeconv();
-    decimal = *(lc->decimal_point);
-    thousands = *(lc->thousands_sep);
-#endif
-
     for (;; cct = 0)
 	switch (*ptr++) {
 	case '+':
@@ -335,9 +327,7 @@ zzlex(void)
 	case ':':
 	    return COLON;
 	case ',':
-	case '.':
-	    if (*(ptr-1) == thousands) return COMMA;
-	    else break;
+	    return COMMA;
 	case '\0':
 	    ptr--;
 	    return EOI;
@@ -362,15 +352,22 @@ zzlex(void)
 	    }
 	/* Fall through! */
 	default:
-	    if (idigit(*--ptr) || *ptr == decimal) {
+	    if (idigit(*--ptr) || *ptr == '.') {
 		char *nptr;
 		for (nptr = ptr; idigit(*nptr); nptr++);
 
-		if (*nptr == decimal || *nptr == 'e' || *nptr == 'E') {
+		if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
 		    /* it's a float */
 		    yyval.type = MN_FLOAT;
+#ifdef USE_LOCALE
+		    prev_locale = setlocale(LC_NUMERIC, NULL);
+		    setlocale(LC_NUMERIC, "POSIX");
+#endif
 		    yyval.u.d = strtod(ptr, &nptr);
-		    if (ptr == nptr || *nptr == decimal ) {
+#ifdef USE_LOCALE
+		    setlocale(LC_NUMERIC, prev_locale);
+#endif
+		    if (ptr == nptr || *nptr == '.' ) {
 			zerr("bad floating point constant", NULL, 0);
 			return EOI;
 		    }