From 5d2f6534686ade26ae839339ff0e8436967aa156 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Sun, 21 Nov 1999 00:18:08 +0000 Subject: zsh-workers/8693 --- Src/math.c | 29 +++++++++++++---------------- 1 file 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; } -- cgit 1.4.1