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

ruby-changes:47879

From: nobu <ko1@a...>
Date: Sun, 24 Sep 2017 03:28:11 +0900 (JST)
Subject: [ruby-changes:47879] nobu:r60001 (trunk): dup String#rpartition return value

nobu	2017-09-23 16:09:06 +0900 (Sat, 23 Sep 2017)

  New Revision: 60001

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

  Log:
    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...>

  Modified files:
    trunk/string.c
    trunk/test/ruby/test_string.rb
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 60000)
+++ test/ruby/test_string.rb	(revision 60001)
@@ -2445,6 +2445,11 @@ CODE https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L2445
     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: string.c
===================================================================
--- string.c	(revision 60000)
+++ string.c	(revision 60001)
@@ -9177,7 +9177,7 @@ rb_str_rpartition(VALUE str, VALUE sep) https://github.com/ruby/ruby/blob/trunk/string.c#L9177
 	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());

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

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