mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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_2@58098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0f70d439c0
commit
0d528f4a29
3 changed files with 6 additions and 5 deletions
2
string.c
2
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);
|
||||
}
|
||||
if (pos >= 0) return LONG2NUM(pos);
|
||||
break;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue