diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:17:48 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2022-04-11 00:17:48 +0200 |
commit | b09f4483416c54c1782824633dfabaf2ec0265b6 (patch) | |
tree | 304bc82642862525ae680c7fbaa249663b10ad57 /Src/math.c | |
parent | 12eb3e5356f2fc3351eed58ef1cef1b8fb83b504 (diff) | |
parent | 6e55c920503071e917619b8cb1a188cd35d772db (diff) | |
download | zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.tar.gz zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.zip |
New upstream version 5.8.1.2-test
Diffstat (limited to 'Src/math.c')
-rw-r--r-- | Src/math.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/Src/math.c b/Src/math.c index 905b910ec..777ad9c31 100644 --- a/Src/math.c +++ b/Src/math.c @@ -162,7 +162,7 @@ static int unary = 1; #define TOKCOUNT 53 /* - * Opeator recedences: in reverse order, i.e. lower number, high precedence. + * Operator precedences: in reverse order, i.e. lower number, high precedence. * These are the C precedences. * * 0 Non-operators: NUM (numeric constant), ID (identifier), @@ -219,7 +219,7 @@ static int c_prec[TOKCOUNT] = }; /* - * Opeator recedences: in reverse order, i.e. lower number, high precedence. + * Operator precedences: in reverse order, i.e. lower number, high precedence. * These are the default zsh precedences. * * 0 Non-operators: NUM (numeric constant), ID (identifier), @@ -831,6 +831,8 @@ zzlex(void) case ' ': /* Fall through! */ case '\t': case '\n': + case '"': /* POSIX says ignore these */ + case Dnull: break; default: if (idigit(*--ptr) || *ptr == '.') @@ -838,13 +840,18 @@ zzlex(void) if (*ptr == '#') { if (*++ptr == '\\' || *ptr == '#') { int v; + char *optr = ptr; ptr++; if (!*ptr) { zerr("bad math expression: character missing after ##"); return EOI; } - ptr = getkeystring(ptr, NULL, GETKEYS_MATH, &v); + if(!(ptr = getkeystring(ptr, NULL, GETKEYS_MATH, &v))) { + zerr("bad math expression: bad character after ##"); + ptr = optr; + return EOI; + } yyval.u.l = v; return NUM; } @@ -856,14 +863,18 @@ zzlex(void) p = ptr; ptr = ie; - if (ie - p == 3) { - if (strncasecmp(p, "NaN", 3) == 0) { + if (ie - p == 3 && !EMULATION(EMULATE_SH)) { + if ((p[0] == 'N' || p[0] == 'n') && + (p[1] == 'A' || p[1] == 'a') && + (p[2] == 'N' || p[2] == 'n')) { yyval.type = MN_FLOAT; yyval.u.d = 0.0; yyval.u.d /= yyval.u.d; return NUM; } - else if (strncasecmp(p, "Inf", 3) == 0) { + else if ((p[0] == 'I' || p[0] == 'i') && + (p[1] == 'N' || p[1] == 'n') && + (p[2] == 'F' || p[2] == 'f')) { yyval.type = MN_FLOAT; yyval.u.d = 0.0; yyval.u.d = 1.0 / yyval.u.d; |