mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-27 04:40:59 +01:00
23165: fix problems with bases: error if over 36 and don't interpret octal
This commit is contained in:
parent
9ed500a1cd
commit
2c92d005d7
5 changed files with 51 additions and 10 deletions
34
Src/math.c
34
Src/math.c
|
|
@ -216,17 +216,33 @@ lexconstant(void)
|
|||
lastbase = 16;
|
||||
return NUM;
|
||||
}
|
||||
else if (isset(OCTALZEROES) &&
|
||||
(memchr(nptr, '.', strlen(nptr)) == NULL) &&
|
||||
idigit(*nptr)) {
|
||||
yyval.u.l = zstrtol(ptr, &ptr, 0);
|
||||
lastbase = 8;
|
||||
return NUM;
|
||||
else if (isset(OCTALZEROES))
|
||||
{
|
||||
char *ptr2;
|
||||
|
||||
/*
|
||||
* Make sure this is a real octal constant;
|
||||
* it can't be a base indication (always decimal)
|
||||
* or a floating point number.
|
||||
*/
|
||||
for (ptr2 = nptr; idigit(*ptr2); ptr2++)
|
||||
;
|
||||
|
||||
if (ptr2 > nptr && *ptr2 != '.' && *ptr2 != 'e' &&
|
||||
*ptr2 != 'E' && *ptr2 != '#')
|
||||
{
|
||||
yyval.u.l = zstrtol(ptr, &ptr, 0);
|
||||
lastbase = 8;
|
||||
return NUM;
|
||||
}
|
||||
nptr = ptr2;
|
||||
}
|
||||
}
|
||||
|
||||
while (idigit(*nptr))
|
||||
nptr++;
|
||||
else
|
||||
{
|
||||
while (idigit(*nptr))
|
||||
nptr++;
|
||||
}
|
||||
|
||||
if (*nptr == '.' || *nptr == 'e' || *nptr == 'E') {
|
||||
/* it's a float */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue