summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--parse.y4
-rw-r--r--test/ruby/test_regexp.rb11
3 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 14514b09a8..05bb688308 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/parse.y b/parse.y
index bfddcfb34a..6b2c7111d7 100644
--- a/parse.y
+++ b/parse.y
@@ -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