Simplify number reader; eliminates potentially invalid double-ungetc().
This commit is contained in:
parent
307ed97b45
commit
e18863c3ad
11
reader.c
11
reader.c
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue