зеркало из https://github.com/github/ruby.git
parse.y: relax spaces
* parse.y (parser_tokadd_utf8): relax restriction spaces inside "\u{...}". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56963 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
76bb017ad2
Коммит
80045bc2a9
6
parse.y
6
parse.y
|
@ -5800,6 +5800,8 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
|
|||
|
||||
if (peek(open_brace)) { /* handle \u{...} form */
|
||||
int c, last = nextc();
|
||||
do c = nextc(); while (ISSPACE(c));
|
||||
pushback(c);
|
||||
do {
|
||||
if (regexp_literal) tokadd(last);
|
||||
codepoint = scan_hex(lex_p, 6, &numlen);
|
||||
|
@ -5816,7 +5818,8 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
|
|||
codepoint, (int)numlen)) {
|
||||
return 0;
|
||||
}
|
||||
if (ISSPACE(c = nextc())) last = c;
|
||||
while (ISSPACE(c = nextc())) last = c;
|
||||
pushback(c);
|
||||
} while (string_literal && c != close_brace);
|
||||
|
||||
if (c != close_brace) {
|
||||
|
@ -5825,6 +5828,7 @@ parser_tokadd_utf8(struct parser_params *parser, rb_encoding **encp,
|
|||
}
|
||||
|
||||
if (regexp_literal) tokadd(close_brace);
|
||||
nextc();
|
||||
}
|
||||
else { /* handle \uxxxx form */
|
||||
codepoint = scan_hex(lex_p, 4, &numlen);
|
||||
|
|
|
@ -260,9 +260,9 @@ EOS
|
|||
eval %q("\u{123.}") # bad char
|
||||
}
|
||||
|
||||
assert_raise(SyntaxError) { eval %q("\u{123 456 }")} # extra space
|
||||
assert_raise(SyntaxError) { eval %q("\u{ 123 456}")} # extra space
|
||||
assert_raise(SyntaxError) { eval %q("\u{123 456}")} # extra space
|
||||
# assert_raise(SyntaxError) { eval %q("\u{123 456 }")} # extra space
|
||||
# assert_raise(SyntaxError) { eval %q("\u{ 123 456}")} # extra space
|
||||
# assert_raise(SyntaxError) { eval %q("\u{123 456}")} # extra space
|
||||
|
||||
assert_raise(SyntaxError) { eval %q("\uD800") } # surrogate block
|
||||
assert_raise(SyntaxError) { eval %q("\uDCBA") } # surrogate block
|
||||
|
|
Загрузка…
Ссылка в новой задаче