ruby-changes:22847
From: nobu <ko1@a...>
Date: Sun, 4 Mar 2012 23:21:25 +0900 (JST)
Subject: [ruby-changes:22847] nobu:r34896 (trunk): * parse.y (parser_tokadd_string): regexp engine doesn't need
nobu 2012-03-04 23:21:13 +0900 (Sun, 04 Mar 2012) New Revision: 34896 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34896 Log: * parse.y (parser_tokadd_string): regexp engine doesn't need terminators to be escaped. [ruby-core:40364][Bug #5484] Modified files: trunk/ChangeLog trunk/parse.y trunk/test/ruby/test_regexp.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34895) +++ ChangeLog (revision 34896) @@ -1,3 +1,8 @@ +Sun Mar 4 23:21:10 2012 Nobuyoshi Nakada <nobu@r...> + + * parse.y (parser_tokadd_string): regexp engine doesn't need + terminators to be escaped. [ruby-core:40364][Bug #5484] + Sat Mar 3 22:51:46 2012 Tanaka Akira <akr@f...> * process.c (rb_run_exec_options_err): chdir at last to interpret Index: parse.y =================================================================== --- parse.y (revision 34895) +++ parse.y (revision 34896) @@ -6514,6 +6514,10 @@ goto non_ascii; } if (func & STR_FUNC_REGEXP) { + if (c == term) { + tokadd(c); + continue; + } pushback(c); if ((c = tokadd_escape(&enc)) < 0) return -1; Index: test/ruby/test_regexp.rb =================================================================== --- test/ruby/test_regexp.rb (revision 34895) +++ test/ruby/test_regexp.rb (revision 34896) @@ -155,7 +155,10 @@ end def test_source + bug5484 = ']ruby-core:40364]' assert_equal('', //.source) + assert_equal('\:', /\:/.source, bug5484) + assert_equal(':', %r:\::.source, bug5484) end def test_inspect @@ -369,9 +372,11 @@ end def test_equal - assert_equal(true, /abc/ == /abc/) - assert_equal(false, /abc/ == /abc/m) - assert_equal(false, /abc/ == /abd/) + bug5484 = ']ruby-core:40364]' + assert_equal(/abc/, /abc/) + assert_not_equal(/abc/, /abc/m) + assert_not_equal(/abc/, /abd/) + assert_equal(/\/foo/, Regexp.new('/foo'), bug5484) end def test_match -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/