about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-11-10 19:13:33 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-11-10 19:13:33 +0000
commite697a4eaaa6143980c54ba9f32a63d2b7d58882d (patch)
tree01a6567ea21d40ef788879c1e639e959b26fc7b2
parent0d3528817d6f3d86d10dcf0e53b39af0945ca588 (diff)
downloadzsh-e697a4eaaa6143980c54ba9f32a63d2b7d58882d.tar.gz
zsh-e697a4eaaa6143980c54ba9f32a63d2b7d58882d.tar.xz
zsh-e697a4eaaa6143980c54ba9f32a63d2b7d58882d.zip
zsh-workers/8609
-rw-r--r--Src/math.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/Src/math.c b/Src/math.c
index e0e13ee35..a2c123da4 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -184,9 +184,20 @@ static int type[TOKCOUNT] =
 static int
 zzlex(void)
 {
+    char decimal = '.', thousands = ',';
     int cct = 0;
+#ifdef USE_LOCALE
+    struct lconv *lc;
+#endif
 
     yyval.type = MN_INTEGER;
+
+#ifdef USE_LOCALE
+    lc = localeconv();
+    decimal = *(lc->decimal_point);
+    thousands = *(lc->thousands_sep);
+#endif
+
     for (;; cct = 0)
 	switch (*ptr++) {
 	case '+':
@@ -324,7 +335,9 @@ zzlex(void)
 	case ':':
 	    return COLON;
 	case ',':
-	    return COMMA;
+	case '.':
+	    if (*(ptr-1) == thousands) return COMMA;
+	    else break;
 	case '\0':
 	    ptr--;
 	    return EOI;
@@ -349,15 +362,15 @@ zzlex(void)
 	    }
 	/* Fall through! */
 	default:
-	    if (idigit(*--ptr) || *ptr == '.') {
+	    if (idigit(*--ptr) || *ptr == decimal) {
 		char *nptr;
 		for (nptr = ptr; idigit(*nptr); nptr++);
 
-		if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
+		if (*nptr == decimal || *nptr == 'e' || *nptr == 'E') {
 		    /* it's a float */
 		    yyval.type = MN_FLOAT;
 		    yyval.u.d = strtod(ptr, &nptr);
-		    if (ptr == nptr || *nptr == '.') {
+		    if (ptr == nptr || *nptr == decimal ) {
 			zerr("bad floating point constant", NULL, 0);
 			return EOI;
 		    }