summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 16:41:00 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-27 16:41:00 +0000
commitd8a1986a05110b2468a256ab94936ef482f010bb (patch)
treedbf2441e933722e936c9c0b0b67cbc01baf83726
parent39ee1e953f8093e1ca3dc418648cd479e24c3b9b (diff)
merge revision(s) 57374: [Backport #13135]
string.c: rindex(//) should set $~. This seems a bug introduced by r520 (1.4.0). [ruby-core:79110] [Bug #13135] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--string.c6
-rw-r--r--test/ruby/test_string.rb3
-rw-r--r--version.h2
3 files changed, 6 insertions, 5 deletions
diff --git a/string.c b/string.c
index f7480cd43b..174f34047b 100644
--- a/string.c
+++ b/string.c
@@ -3298,10 +3298,8 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
enc, single_byte_optimizable(str));
- if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
- pos = rb_reg_search(sub, str, pos, 1);
- pos = rb_str_sublen(str, pos);
- }
+ pos = rb_reg_search(sub, str, pos, 1);
+ pos = rb_str_sublen(str, pos);
if (pos >= 0) return LONG2NUM(pos);
break;
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index bf7a2d0f9b..2a19b055be 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1110,6 +1110,9 @@ class TestString < Test::Unit::TestCase
assert_nil("foo".rindex(//, -100))
assert_nil($~)
+
+ assert_equal(3, "foo".rindex(//))
+ assert_equal([3, 3], $~.offset(0))
end
def test_rjust
diff --git a/version.h b/version.h
index 9eb5d5b06d..b756fa304a 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.3"
#define RUBY_RELEASE_DATE "2017-03-28"
-#define RUBY_PATCHLEVEL 285
+#define RUBY_PATCHLEVEL 286
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3