int() test passed

This commit is contained in:
xyb 2014-01-15 19:58:11 +08:00
parent 82e61bdc24
commit 3270fb4be6
2 changed files with 7 additions and 9 deletions

View File

@ -49,16 +49,14 @@ long strtonum(const char *restrict s, int base) {
p -= 2;
}
} else if (base == 8 && c == '0') {
if ((c | 32) == 'o') {
base = 8;
} else {
goto value_error;
c = *(p++);
if ((c | 32) != 'o') {
p -= 2;
}
} else if (base == 2 && c == '0') {
if ((c | 32) == 'b') {
base = 2;
} else {
goto value_error;
c = *(p++);
if ((c | 32) != 'b') {
p -= 2;
}
} else {
if (base == 0) base = 10;

View File

@ -38,7 +38,7 @@ def test(value, base):
test(' 1x', 0)
test(' 1\02 ', 0)
test(' 1' + chr(2) + ' ', 0)
test('', 0)
test(' ', 0)
test(' \t\t ', 0)