diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-04 14:21:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-03-04 14:21:13 +0000 |
commit | 68a16f9a2dfbb773744adaa63468449838761015 (patch) | |
tree | 01dc68d437495d694af5e8eee928f3d909229b52 | |
parent | b212b84fc1ebe42e559a078ef9e78e9b7e51907b (diff) | |
download | ruby-68a16f9a2dfbb773744adaa63468449838761015.tar.gz |
* parse.y (parser_tokadd_string): regexp engine doesn't need
terminators to be escaped. [ruby-core:40364][Bug #5484]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 4 | ||||
-rw-r--r-- | test/ruby/test_regexp.rb | 11 |
3 files changed, 17 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Sun Mar 4 23:21:10 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * 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@fsij.org> * process.c (rb_run_exec_options_err): chdir at last to interpret @@ -6514,6 +6514,10 @@ parser_tokadd_string(struct parser_params *parser, goto non_ascii; } if (func & STR_FUNC_REGEXP) { + if (c == term) { + tokadd(c); + continue; + } pushback(c); if ((c = tokadd_escape(&enc)) < 0) return -1; diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index b1490ed06d..a86e8c2584 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -155,7 +155,10 @@ class TestRegexp < Test::Unit::TestCase 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 @@ class TestRegexp < Test::Unit::TestCase 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 |