Josh discovered a bug parsing negative numbers with leading zeros

("-0.3") which also affected ones of the form "-.3".  This got
introduced a few months back, I'm not sure how it went undetected for
so long...
This commit is contained in:
andy
2005-07-21 23:03:26 +00:00
parent f93ea20d5e
commit 7c2575d723

View File

@@ -175,6 +175,13 @@ static int tonum(unsigned char* s, int len, double* result)
if(len == 1 && s[0] == '.')
return 0;
// Strip off the leading negative sign first, so we can correctly
// parse things like -.xxx which would otherwise confuse
// readsigned.
if(len > 1 && s[0] == '-' && s[1] != '-') {
sgn = -1; s++; len--;
}
// Read the integer part
i = readsigned(s, len, i, &val);
if(val < 0) { sgn = -1; val = -val; }