Simplify number reader; eliminates potentially invalid double-ungetc().

This commit is contained in:
Jesse D. McDonald 2009-11-21 23:45:56 -06:00
parent 307ed97b45
commit e18863c3ad
1 changed files with 3 additions and 8 deletions

View File

@ -342,29 +342,24 @@ static value_t read_number(reader_state_t *state)
{
case 'X':
case 'x':
next_char(state);
radix = 16;
next_char(state);
break;
case 'B':
case 'b':
next_char(state);
radix = 2;
next_char(state);
break;
case '0' ... '9':
ungetc(state->ch, state->file);
state->ch = '0';
radix = 8;
break;
default:
ungetc(state->ch, state->file);
state->ch = '0';
radix = 10;
break;
}
if (radix != 8)
if (radix != 10)
{
/* Make sure we have at least one digit; if octal then the '0' counts instead */
release_assert(isalnum(state->ch));
release_assert(char_to_digit(state->ch) < radix);
}