ruby-changes:48650
From: nobu <ko1@a...>
Date: Wed, 15 Nov 2017 00:37:53 +0900 (JST)
Subject: [ruby-changes:48650] nobu:r60766 (trunk): parse.y: zero codepoints
nobu 2017-11-15 00:37:48 +0900 (Wed, 15 Nov 2017) New Revision: 60766 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60766 Log: parse.y: zero codepoints * parse.y (parser_tokadd_utf8): relax restriction to allow zero or more codepoints. fixup r59417. https://github.com/ruby/ruby/commit/7e8b910#commitcomment-25602670 Modified files: trunk/parse.y trunk/test/ruby/test_parse.rb Index: test/ruby/test_parse.rb =================================================================== --- test/ruby/test_parse.rb (revision 60765) +++ test/ruby/test_parse.rb (revision 60766) @@ -517,6 +517,8 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L517 assert_syntax_error(src, /:#{__LINE__}: unterminated/o) assert_syntax_error('"\u{100000000}"', /invalid Unicode escape/) + assert_equal("", eval('"\u{}"')) + assert_equal("", eval('"\u{ }"')) assert_equal("\x81", eval('"\C-\M-a"')) assert_equal("\177", eval('"\c?"')) @@ -555,6 +557,10 @@ class TestParse < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_parse.rb#L557 assert_nothing_raised(SyntaxError, bug) do assert_equal(sym, eval(':"foo\u{0}bar"')) end + assert_nothing_raised(SyntaxError) do + assert_equal(:foobar, eval(':"foo\u{}bar"')) + assert_equal(:foobar, eval(':"foo\u{ }bar"')) + end end def test_parse_string Index: parse.y =================================================================== --- parse.y (revision 60765) +++ parse.y (revision 60766) @@ -5999,7 +5999,7 @@ parser_tokadd_utf8(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L5999 int c, last = nextc(); if (lex_p >= lex_pend) goto unterminated; while (ISSPACE(c = *lex_p) && ++lex_p < lex_pend); - do { + while (c != close_brace) { if (regexp_literal) tokadd(last); if (!parser_tokadd_codepoint(parser, encp, regexp_literal, TRUE)) { break; @@ -6008,7 +6008,7 @@ parser_tokadd_utf8(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L6008 if (++lex_p >= lex_pend) goto unterminated; last = c; } - } while (c != close_brace); + } if (c != close_brace) { unterminated: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/