diff options
-rw-r--r-- | string.c | 6 | ||||
-rw-r--r-- | test/ruby/test_string.rb | 3 |
2 files changed, 5 insertions, 4 deletions
@@ -3516,10 +3516,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_PTR(sub) || 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 f2fcf3fb25..d5166a82bc 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1227,6 +1227,9 @@ CODE assert_nil("foo".rindex(//, -100)) assert_nil($~) + + assert_equal(3, "foo".rindex(//)) + assert_equal([3, 3], $~.offset(0)) end def test_rjust |