diff options
| author | nagachika <nagachika@ruby-lang.org> | 2023-11-10 11:41:57 +0900 |
|---|---|---|
| committer | nagachika <nagachika@ruby-lang.org> | 2023-11-10 11:41:57 +0900 |
| commit | 482e1f573ee45ef562cc6d218ba26d44660f8e0a (patch) | |
| tree | 451d409c16698ce085217fe10f243df68f1d973f /parse.y | |
| parent | 2aaa9af75989bb0993a44e9690ed2ca890b2ff91 (diff) | |
merge revision(s) 17b0643392749f45b7aacb64fc1c1bd704d42b4c: [Backport #19924]
[Bug #19924] Source code should be unsigned char stream
Use `peekc` or `nextc` to fetch the next character, instead of reading
from `lex.pcur` directly, for compilers that plain char is signed.
---
parse.y | 10 +++++-----
test/ruby/test_parse.rb | 2 ++
2 files changed, 7 insertions(+), 5 deletions(-)
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -7286,9 +7286,9 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp, * invalid unicode escapes are allowed in comments. The regexp parser * does its own validation and will catch any issues. */ - int c = *p->lex.pcur; - tokadd(p, c); - for (c = *++p->lex.pcur; p->lex.pcur < p->lex.pend; c = *++p->lex.pcur) { + tokadd(p, open_brace); + while (++p->lex.pcur < p->lex.pend) { + int c = peekc(p); if (c == close_brace) { tokadd(p, c); ++p->lex.pcur; @@ -7678,7 +7678,7 @@ tokadd_string(struct parser_params *p, --*nest; } else if ((func & STR_FUNC_EXPAND) && c == '#' && p->lex.pcur < p->lex.pend) { - int c2 = *p->lex.pcur; + unsigned char c2 = *p->lex.pcur; if (c2 == '$' || c2 == '@' || c2 == '{') { pushback(p, c); break; @@ -9313,7 +9313,7 @@ parse_qmark(struct parser_params *p, int space_seen) enc = rb_utf8_encoding(); tokadd_utf8(p, &enc, -1, 0, 0); } - else if (!lex_eol_p(p) && !(c = *p->lex.pcur, ISASCII(c))) { + else if (!ISASCII(c = peekc(p))) { nextc(p); if (tokadd_mbchar(p, c) == -1) return 0; } |
