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

ruby-changes:50656

From: usa <ko1@a...>
Date: Mon, 19 Mar 2018 00:00:49 +0900 (JST)
Subject: [ruby-changes:50656] usa:r62818 (ruby_2_3): merge revision(s) 60000, 60001, 60002: [Backport #13925]

usa	2018-03-19 00:00:46 +0900 (Mon, 19 Mar 2018)

  New Revision: 62818

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

  Log:
    merge revision(s) 60000,60001,60002: [Backport #13925]
    
    dup String#partition return value
    
    * string.c (rb_str_partition): return duplicated receiver, when no
      splits.  [ruby-core:82911] [Bug#13925]
    
    Author:    Seiei Miyagi <hanachin@g...>
    
    dup String#rpartition return value
    
    * string.c (rb_str_rpartition): return duplicated receiver, when
      no splits.  [ruby-core:82911] [Bug#13925]
    
    Author:    Seiei Miyagi <hanachin@g...>
    
    dup String#split return value
    
    * string.c (rb_str_split): return duplicated receiver, when no
      splits.  patched by tompng (tomoya ishida) in [ruby-core:82911],
      and the test case by Seiei Miyagi <hanachin@g...>.
      [Bug#13925] [Fix GH-1705]

  Modified directories:
    branches/ruby_2_3/
  Modified files:
    branches/ruby_2_3/ChangeLog
    branches/ruby_2_3/string.c
    branches/ruby_2_3/test/ruby/test_string.rb
    branches/ruby_2_3/version.h
Index: ruby_2_3/test/ruby/test_string.rb
===================================================================
--- ruby_2_3/test/ruby/test_string.rb	(revision 62817)
+++ ruby_2_3/test/ruby/test_string.rb	(revision 62818)
@@ -1362,6 +1362,11 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_string.rb#L1362
     }
   end
 
+  def test_split_dupped
+    s = "abc"
+    s.split("b", 1).map(&:upcase!)
+    assert_equal("abc", s)
+  end
   def test_squeeze
     assert_equal(S("abc"), S("aaabbbbccc").squeeze)
     assert_equal(S("aa bb cc"), S("aa   bb      cc").squeeze(S(" ")))
@@ -2051,7 +2056,12 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_string.rb#L2056
     end
 
     assert_equal(["\u30E6\u30FC\u30B6", "@", "\u30C9\u30E1.\u30A4\u30F3"],
-      "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/))
+                 "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".partition(/[@.]/))
+
+    bug = '[ruby-core:82911]'
+    hello = "hello"
+    hello.partition("hi").map(&:upcase!)
+    assert_equal("hello", hello, bug)
   end
 
   def test_rpartition
@@ -2071,6 +2081,11 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_string.rb#L2081
     bug8138 = '[ruby-dev:47183]'
     assert_equal(["\u30E6\u30FC\u30B6@\u30C9\u30E1", ".", "\u30A4\u30F3"],
       "\u30E6\u30FC\u30B6@\u30C9\u30E1.\u30A4\u30F3".rpartition(/[@.]/), bug8138)
+
+    bug = '[ruby-core:82911]'
+    hello = "hello"
+    hello.rpartition("hi").map(&:upcase!)
+    assert_equal("hello", hello, bug)
   end
 
   def test_setter
Index: ruby_2_3/version.h
===================================================================
--- ruby_2_3/version.h	(revision 62817)
+++ ruby_2_3/version.h	(revision 62818)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1
 #define RUBY_VERSION "2.3.7"
 #define RUBY_RELEASE_DATE "2018-03-18"
-#define RUBY_PATCHLEVEL 419
+#define RUBY_PATCHLEVEL 420
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_3/string.c
===================================================================
--- ruby_2_3/string.c	(revision 62817)
+++ ruby_2_3/string.c	(revision 62818)
@@ -6836,7 +6836,7 @@ rb_str_split_m(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_3/string.c#L6836
 	else if (lim == 1) {
 	    if (RSTRING_LEN(str) == 0)
 		return rb_ary_new2(0);
-	    return rb_ary_new3(1, str);
+	    return rb_ary_new3(1, rb_str_dup(str));
 	}
 	i = 1;
     }
@@ -8442,7 +8442,7 @@ rb_str_partition(VALUE str, VALUE sep) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/string.c#L8442
 	pos = rb_reg_search(sep, str, 0, 0);
 	if (pos < 0) {
 	  failed:
-	    return rb_ary_new3(3, str, str_new_empty(str), str_new_empty(str));
+	    return rb_ary_new3(3, rb_str_dup(str), str_new_empty(str), str_new_empty(str));
 	}
 	sep = rb_str_subpat(str, sep, INT2FIX(0));
 	if (pos == 0 && RSTRING_LEN(sep) == 0) goto failed;
@@ -8495,7 +8495,7 @@ rb_str_rpartition(VALUE str, VALUE sep) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/string.c#L8495
 	pos = rb_str_rindex(str, sep, pos);
     }
     if (pos < 0) {
-	return rb_ary_new3(3, str_new_empty(str), str_new_empty(str), str);
+       return rb_ary_new3(3, str_new_empty(str), str_new_empty(str), rb_str_dup(str));
     }
     if (regex) {
 	sep = rb_reg_nth_match(0, rb_backref_get());
Index: ruby_2_3/ChangeLog
===================================================================
--- ruby_2_3/ChangeLog	(revision 62817)
+++ ruby_2_3/ChangeLog	(revision 62818)
@@ -1,3 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1
+Sun Mar 18 23:59:32 2018  Nobuyoshi Nakada  <nobu@r...>
+
+	dup String#partition return value
+
+	* string.c (rb_str_partition): return duplicated receiver, when no
+	  splits. [Bug#13925]
+
+	Author: Seiei Miyagi hanachin@g...
+
+	dup String#rpartition return value
+
+	* string.c (rb_str_rpartition): return duplicated receiver, when no
+	  splits. [Bug#13925]
+
+	Author: Seiei Miyagi hanachin@g...
+
+	dup String#split return value
+
+	* string.c (rb_str_split): return duplicated receiver, when no splits.
+	  patched by tompng (tomoya ishida) in , and the test case by Seiei
+	  Miyagi hanachin@g... [Bug#13925] [Fix GH-1705]
+
 Sun Mar 18 23:57:32 2018  Nobuyoshi Nakada  <nobu@r...>
 
 	ruby.c: paragraph mode by -00
Index: ruby_2_3
===================================================================
--- ruby_2_3	(revision 62817)
+++ ruby_2_3	(revision 62818)

Property changes on: ruby_2_3
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r60000-60002

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

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