Skip to content

Commit

Permalink
[Bug #19743] All but EOF can be read again after push-back
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Jun 22, 2023
1 parent 8142728 commit 1344de5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions parse.y
Expand Up @@ -7121,6 +7121,7 @@ static void
pushback(struct parser_params *p, int c)
{
if (c == -1) return;
p->eofp = 0;
p->lex.pcur--;
if (p->lex.pcur > p->lex.pbeg && p->lex.pcur[0] == '\n' && p->lex.pcur[-1] == '\r') {
p->lex.pcur--;
Expand Down Expand Up @@ -9164,6 +9165,7 @@ parse_numeric(struct parser_params *p, int c)
c = nextc(p);
if (c != '-' && c != '+' && !ISDIGIT(c)) {
pushback(p, c);
c = nondigit;
nondigit = 0;
goto decode_num;
}
Expand Down
2 changes: 2 additions & 0 deletions test/ruby/test_parse.rb
Expand Up @@ -1138,6 +1138,8 @@ def test_unexpected_token_after_numeric
assert_syntax_error('0000xyz', /^ \^~~\Z/)
assert_syntax_error('1.2i1.1', /^ \^~~\Z/)
assert_syntax_error('1.2.3', /^ \^~\Z/)
assert_syntax_error('1.', /unexpected end-of-input/)
assert_syntax_error('1e', /expecting end-of-input/)
end

def test_truncated_source_line
Expand Down

0 comments on commit 1344de5

Please sign in to comment.