mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
[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.
This commit is contained in:
parent
2dca02e273
commit
17b0643392
2 changed files with 7 additions and 5 deletions
10
parse.y
10
parse.y
|
@ -7911,9 +7911,9 @@ tokadd_utf8(struct parser_params *p, rb_encoding **encp,
|
||||||
* invalid unicode escapes are allowed in comments. The regexp parser
|
* invalid unicode escapes are allowed in comments. The regexp parser
|
||||||
* does its own validation and will catch any issues.
|
* does its own validation and will catch any issues.
|
||||||
*/
|
*/
|
||||||
int c = *p->lex.pcur;
|
tokadd(p, open_brace);
|
||||||
tokadd(p, c);
|
while (++p->lex.pcur < p->lex.pend) {
|
||||||
for (c = *++p->lex.pcur; p->lex.pcur < p->lex.pend; c = *++p->lex.pcur) {
|
int c = peekc(p);
|
||||||
if (c == close_brace) {
|
if (c == close_brace) {
|
||||||
tokadd(p, c);
|
tokadd(p, c);
|
||||||
++p->lex.pcur;
|
++p->lex.pcur;
|
||||||
|
@ -8310,7 +8310,7 @@ tokadd_string(struct parser_params *p,
|
||||||
--*nest;
|
--*nest;
|
||||||
}
|
}
|
||||||
else if ((func & STR_FUNC_EXPAND) && c == '#' && !lex_eol_p(p)) {
|
else if ((func & STR_FUNC_EXPAND) && c == '#' && !lex_eol_p(p)) {
|
||||||
int c2 = *p->lex.pcur;
|
unsigned char c2 = *p->lex.pcur;
|
||||||
if (c2 == '$' || c2 == '@' || c2 == '{') {
|
if (c2 == '$' || c2 == '@' || c2 == '{') {
|
||||||
pushback(p, c);
|
pushback(p, c);
|
||||||
break;
|
break;
|
||||||
|
@ -9916,7 +9916,7 @@ parse_qmark(struct parser_params *p, int space_seen)
|
||||||
enc = rb_utf8_encoding();
|
enc = rb_utf8_encoding();
|
||||||
tokadd_utf8(p, &enc, -1, 0, 0);
|
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);
|
nextc(p);
|
||||||
if (tokadd_mbchar(p, c) == -1) return 0;
|
if (tokadd_mbchar(p, c) == -1) return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -633,6 +633,8 @@ class TestParse < Test::Unit::TestCase
|
||||||
assert_syntax_error("?\\M-\x01", 'Invalid escape character syntax')
|
assert_syntax_error("?\\M-\x01", 'Invalid escape character syntax')
|
||||||
assert_syntax_error("?\\M-\\C-\x01", 'Invalid escape character syntax')
|
assert_syntax_error("?\\M-\\C-\x01", 'Invalid escape character syntax')
|
||||||
assert_syntax_error("?\\C-\\M-\x01", 'Invalid escape character syntax')
|
assert_syntax_error("?\\C-\\M-\x01", 'Invalid escape character syntax')
|
||||||
|
|
||||||
|
assert_equal("\xff", eval("# encoding: ascii-8bit\n""?\\\xFF"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_percent
|
def test_percent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue