SCP: Tolerate commas in decimal numbers during expression evaluation

This commit is contained in:
Mark Pizzolato 2020-03-22 18:55:14 -07:00
parent 614ad52091
commit 03466a6806

30
scp.c
View file

@ -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';
} }
} }