зеркало из https://github.com/github/ruby.git
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/trunk@57374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
af9a151f0b
Коммит
d33726b837
6
string.c
6
string.c
|
@ -3516,10 +3516,8 @@ rb_str_rindex_m(int argc, VALUE *argv, VALUE str)
|
||||||
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
|
pos = str_offset(RSTRING_PTR(str), RSTRING_END(str), pos,
|
||||||
enc, single_byte_optimizable(str));
|
enc, single_byte_optimizable(str));
|
||||||
|
|
||||||
if (!RREGEXP_PTR(sub) || RREGEXP_SRC_LEN(sub)) {
|
pos = rb_reg_search(sub, str, pos, 1);
|
||||||
pos = rb_reg_search(sub, str, pos, 1);
|
pos = rb_str_sublen(str, pos);
|
||||||
pos = rb_str_sublen(str, pos);
|
|
||||||
}
|
|
||||||
if (pos >= 0) return LONG2NUM(pos);
|
if (pos >= 0) return LONG2NUM(pos);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1227,6 +1227,9 @@ CODE
|
||||||
|
|
||||||
assert_nil("foo".rindex(//, -100))
|
assert_nil("foo".rindex(//, -100))
|
||||||
assert_nil($~)
|
assert_nil($~)
|
||||||
|
|
||||||
|
assert_equal(3, "foo".rindex(//))
|
||||||
|
assert_equal([3, 3], $~.offset(0))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_rjust
|
def test_rjust
|
||||||
|
|
Загрузка…
Ссылка в новой задаче