[前][次][番号順一覧][スレッド一覧]

ruby-changes:45791

From: naruse <ko1@a...>
Date: Sun, 12 Mar 2017 02:35:08 +0900 (JST)
Subject: [ruby-changes:45791] naruse:r57864 (ruby_2_4): merge revision(s) 57374: [Backport #13135]

naruse	2017-03-12 02:35:03 +0900 (Sun, 12 Mar 2017)

  New Revision: 57864

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57864

  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_4/
  Modified files:
    branches/ruby_2_4/string.c
    branches/ruby_2_4/test/ruby/test_string.rb
    branches/ruby_2_4/version.h
Index: ruby_2_4/test/ruby/test_string.rb
===================================================================
--- ruby_2_4/test/ruby/test_string.rb	(revision 57863)
+++ ruby_2_4/test/ruby/test_string.rb	(revision 57864)
@@ -1217,6 +1217,9 @@ CODE https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_string.rb#L1217
 
     assert_nil("foo".rindex(//, -100))
     assert_nil($~)
+
+    assert_equal(3, "foo".rindex(//))
+    assert_equal([3, 3], $~.offset(0))
   end
 
   def test_rjust
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 57863)
+++ ruby_2_4/version.h	(revision 57864)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-12"
-#define RUBY_PATCHLEVEL 29
+#define RUBY_PATCHLEVEL 30
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_4/string.c
===================================================================
--- ruby_2_4/string.c	(revision 57863)
+++ ruby_2_4/string.c	(revision 57864)
@@ -3493,10 +3493,8 @@ rb_str_rindex_m(int argc, VALUE *argv, V https://github.com/ruby/ruby/blob/trunk/ruby_2_4/string.c#L3493
 	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;
 

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57374


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]