summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 89723a08da..ade2be20b9 100644
--- a/string.c
+++ b/string.c
@@ -3083,10 +3083,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 3375a8a3a3..69df6472d1 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1126,6 +1126,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 297184cedb..259c6ddd95 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.7"
#define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 430
+#define RUBY_PATCHLEVEL 431
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3