ruby-changes:44890
From: nobu <ko1@a...>
Date: Fri, 2 Dec 2016 11:47:17 +0900 (JST)
Subject: [ruby-changes:44890] nobu:r56963 (trunk): parse.y: relax spaces
nobu 2016-12-02 11:47:11 +0900 (Fri, 02 Dec 2016) New Revision: 56963 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56963 Log: parse.y: relax spaces * parse.y (parser_tokadd_utf8): relax restriction spaces inside "\u{...}". Modified files: trunk/parse.y trunk/test/ruby/test_unicode_escape.rb Index: parse.y =================================================================== --- parse.y (revision 56962) +++ parse.y (revision 56963) @@ -5800,6 +5800,8 @@ parser_tokadd_utf8(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L5800 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 https://github.com/ruby/ruby/blob/trunk/parse.y#L5818 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 https://github.com/ruby/ruby/blob/trunk/parse.y#L5828 } if (regexp_literal) tokadd(close_brace); + nextc(); } else { /* handle \uxxxx form */ codepoint = scan_hex(lex_p, 4, &numlen); Index: test/ruby/test_unicode_escape.rb =================================================================== --- test/ruby/test_unicode_escape.rb (revision 56962) +++ test/ruby/test_unicode_escape.rb (revision 56963) @@ -260,9 +260,9 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_unicode_escape.rb#L260 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/