mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-11 13:01:28 +02:00
zsh-workers/8609
This commit is contained in:
parent
0d3528817d
commit
e697a4eaaa
1 changed files with 17 additions and 4 deletions
21
Src/math.c
21
Src/math.c
|
@ -184,9 +184,20 @@ static int type[TOKCOUNT] =
|
||||||
static int
|
static int
|
||||||
zzlex(void)
|
zzlex(void)
|
||||||
{
|
{
|
||||||
|
char decimal = '.', thousands = ',';
|
||||||
int cct = 0;
|
int cct = 0;
|
||||||
|
#ifdef USE_LOCALE
|
||||||
|
struct lconv *lc;
|
||||||
|
#endif
|
||||||
|
|
||||||
yyval.type = MN_INTEGER;
|
yyval.type = MN_INTEGER;
|
||||||
|
|
||||||
|
#ifdef USE_LOCALE
|
||||||
|
lc = localeconv();
|
||||||
|
decimal = *(lc->decimal_point);
|
||||||
|
thousands = *(lc->thousands_sep);
|
||||||
|
#endif
|
||||||
|
|
||||||
for (;; cct = 0)
|
for (;; cct = 0)
|
||||||
switch (*ptr++) {
|
switch (*ptr++) {
|
||||||
case '+':
|
case '+':
|
||||||
|
@ -324,7 +335,9 @@ zzlex(void)
|
||||||
case ':':
|
case ':':
|
||||||
return COLON;
|
return COLON;
|
||||||
case ',':
|
case ',':
|
||||||
return COMMA;
|
case '.':
|
||||||
|
if (*(ptr-1) == thousands) return COMMA;
|
||||||
|
else break;
|
||||||
case '\0':
|
case '\0':
|
||||||
ptr--;
|
ptr--;
|
||||||
return EOI;
|
return EOI;
|
||||||
|
@ -349,15 +362,15 @@ zzlex(void)
|
||||||
}
|
}
|
||||||
/* Fall through! */
|
/* Fall through! */
|
||||||
default:
|
default:
|
||||||
if (idigit(*--ptr) || *ptr == '.') {
|
if (idigit(*--ptr) || *ptr == decimal) {
|
||||||
char *nptr;
|
char *nptr;
|
||||||
for (nptr = ptr; idigit(*nptr); nptr++);
|
for (nptr = ptr; idigit(*nptr); nptr++);
|
||||||
|
|
||||||
if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
|
if (*nptr == decimal || *nptr == 'e' || *nptr == 'E') {
|
||||||
/* it's a float */
|
/* it's a float */
|
||||||
yyval.type = MN_FLOAT;
|
yyval.type = MN_FLOAT;
|
||||||
yyval.u.d = strtod(ptr, &nptr);
|
yyval.u.d = strtod(ptr, &nptr);
|
||||||
if (ptr == nptr || *nptr == '.') {
|
if (ptr == nptr || *nptr == decimal ) {
|
||||||
zerr("bad floating point constant", NULL, 0);
|
zerr("bad floating point constant", NULL, 0);
|
||||||
return EOI;
|
return EOI;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue