SCP: Tolerate commas in decimal numbers during expression evaluation
This commit is contained in:
parent
614ad52091
commit
03466a6806
1 changed files with 28 additions and 2 deletions
30
scp.c
30
scp.c
|
@ -14778,8 +14778,34 @@ else {
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
}
|
}
|
||||||
else { /* Decimal Number */
|
else { /* Decimal Number */
|
||||||
while (isdigit (*cptr))
|
int digits = 0;
|
||||||
*buf++ = *cptr++;
|
int commas = 0;
|
||||||
|
const char *cp = cptr;
|
||||||
|
|
||||||
|
/* Ignore commas in decimal numbers */
|
||||||
|
while (isdigit (*cp) || (*cp == ',')) {
|
||||||
|
if (*cp == ',')
|
||||||
|
++commas;
|
||||||
|
else
|
||||||
|
++digits;
|
||||||
|
++cp;
|
||||||
|
}
|
||||||
|
if ((commas > 0) && (commas != (digits - 1)/3)) {
|
||||||
|
*stat = SCPE_INVEXPR;
|
||||||
|
return cptr;
|
||||||
|
}
|
||||||
|
while (commas--) {
|
||||||
|
cp -= 4;
|
||||||
|
if (*cp != ',') {
|
||||||
|
*stat = SCPE_INVEXPR;
|
||||||
|
return cptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (isdigit (*cptr) || (*cptr == ',')) {
|
||||||
|
if (*cptr != ',')
|
||||||
|
*buf++ = *cptr;
|
||||||
|
++cptr;
|
||||||
|
}
|
||||||
*buf = '\0';
|
*buf = '\0';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue