ruby-changes:46027
From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 01:29:24 +0900 (JST)
Subject: [ruby-changes:46027] usa:r58098 (ruby_2_2): merge revision(s) 57374: [Backport #13135]
usa 2017-03-26 01:29:17 +0900 (Sun, 26 Mar 2017) New Revision: 58098 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58098 Log: 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] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/string.c branches/ruby_2_2/test/ruby/test_string.rb branches/ruby_2_2/version.h Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 58097) +++ ruby_2_2/version.h (revision 58098) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #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 Index: ruby_2_2/string.c =================================================================== --- ruby_2_2/string.c (revision 58097) +++ ruby_2_2/string.c (revision 58098) @@ -3083,10 +3083,8 @@ rb_str_rindex_m(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ruby_2_2/string.c#L3083 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; Index: ruby_2_2/test/ruby/test_string.rb =================================================================== --- ruby_2_2/test/ruby/test_string.rb (revision 58097) +++ ruby_2_2/test/ruby/test_string.rb (revision 58098) @@ -1126,6 +1126,9 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_string.rb#L1126 assert_nil("foo".rindex(//, -100)) assert_nil($~) + + assert_equal(3, "foo".rindex(//)) + assert_equal([3, 3], $~.offset(0)) end def test_rjust Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r57374 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/