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

ruby-changes:17040

From: mrkn <ko1@a...>
Date: Wed, 18 Aug 2010 18:42:48 +0900 (JST)
Subject: [ruby-changes:17040] Ruby:r29037 (trunk): * array.c (ary_make_shared), test/ruby/test_array.rb (test_permutation): always return the original array when it is shared. [Bug #3708]

mrkn	2010-08-18 18:42:36 +0900 (Wed, 18 Aug 2010)

  New Revision: 29037

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29037

  Log:
    * array.c (ary_make_shared), test/ruby/test_array.rb (test_permutation): always return the original array when it is shared.  [ruby-dev:42067] [Bug #3708]

  Modified files:
    trunk/ChangeLog
    trunk/array.c
    trunk/test/ruby/test_array.rb

Index: array.c
===================================================================
--- array.c	(revision 29036)
+++ array.c	(revision 29037)
@@ -409,10 +409,7 @@
 ary_make_shared(VALUE ary)
 {
     assert(!ARY_EMBED_P(ary));
-    if (ARY_SHARED_P(ary)) {
-	return ARY_SHARED(ary);
-    }
-    else if (ARY_SHARED_ROOT_P(ary)) {
+    if (ARY_SHARED_P(ary) || ARY_SHARED_ROOT_P(ary)) {
 	return ary;
     }
     else if (OBJ_FROZEN(ary)) {
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29036)
+++ ChangeLog	(revision 29037)
@@ -1,3 +1,10 @@
+Wed Aug 18 18:36:32 2010  Kenta Murata  <mrkn@m...>
+
+	* array.c (ary_make_shared),
+	  test/ruby/test_array.rb (test_permutation):
+	  always return the original array when it is shared.
+	  [ruby-dev:42067] [Bug #3708]
+
 Wed Aug 18 01:37:49 2010  NARUSE, Yui  <naruse@r...>
 
 	* regcomp.c: revert r26701; it introduces Bug #3681.
Index: test/ruby/test_array.rb
===================================================================
--- test/ruby/test_array.rb	(revision 29036)
+++ test/ruby/test_array.rb	(revision 29037)
@@ -1549,6 +1549,9 @@
     a.permutation {|x| b << x; a.replace(@cls[9, 8, 7, 6]) }
     assert_equal(@cls[9, 8, 7, 6], a)
     assert_equal(@cls[1, 2, 3, 4].permutation.to_a, b)
+
+    bug3708 = '[ruby-dev:42067]'
+    assert_equal(b, @cls[0, 1, 2, 3, 4][1, 4].permutation.to_a, bug3708)
   end
 
   def test_repeated_permutation

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

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