[#41918] [Feature #3647] Array#sample(n, replace=false) — Kenta Murata <redmine@...>

Feature #3647: Array#sample(n, replace=false)

11 messages 2010/08/03

[#41966] [Bug #3673] PTY.getpty with IO.pipe doesn't finish on FreeBSD — Yui NARUSE <redmine@...>

Bug #3673: PTY.getpty with IO.pipe doesn't finish on FreeBSD

9 messages 2010/08/10

[#41969] [Feature #3675] String#prepend, String#>> — Sora Harakami <redmine@...>

Feature #3675: String#prepend, String#>>

15 messages 2010/08/10
[#41976] Re: [Feature #3675] String#prepend, String#>> — Yukihiro Matsumoto <matz@...> 2010/08/10

まつもと ゆきひろです

[#41974] Re: [ruby-cvs:36157] Ruby:r28955 (trunk): * complex.c (nucomp_to_[ifr]): don't allow complex with in-exact — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

7 messages 2010/08/10

[#42003] WEBrickに関するセキュリティ修正 (CVE-2010-0541) — Hideki Yamane <henrich@...>

12 messages 2010/08/11

[#42090] Math::atan2(0, 0) on ruby 1.9.2 — KUBO Takehiro <kubo@...>

久保です。

18 messages 2010/08/22
[#42092] Re: Math::atan2(0, 0) on ruby 1.9.2 — Kenta Murata <muraken@...> 2010/08/22

=1B$B$`$i$?$G$9!#=1B(B

[#42166] Ruby'sライセンスの、BSDLとのデュアルライセンスへの変更 — "NARUSE, Yui" <naruse@...>

Ruby's ライセンスは BSDL と Ruby's のデュアルライセンスになります。

14 messages 2010/08/31

[ruby-dev:42068] Re: [Bug #3708] Array#permutation がおかしな結果を返す

From: Kenta Murata <muraken@...>
Date: 2010-08-18 09:16:13 UTC
List: ruby-dev #42068
=1B$B$`$i$?$G$9!#=1B(B

On 2010/08/18, at 16:33, Shumpei Akai wrote:

> =
Array#permutation=1B$B$N7k2L$K!$G[Ns$K4^$^$l$F$$$J$$$O$:$NCM$,F~$C$F$$$^$9=
=1B(B
>=20
> % ./ruby_head -e "p [0,1,2,3,4][1,4].permutation.to_a"
> [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], =
[0, 3, 2, 1], [1, 0, 2, 3], [1, 0, 3, 2], [1, 2, 0, 3], [1, 2, 3, 0], =
[1, 3, 0, 2], [1, 3, 2, 0], [2, 0, 1, 3], [2, 0, 3, 1], [2, 1, 0, 3], =
[2, 1, 3, 0], [2, 3, 0, 1], [2, 3, 1, 0], [3, 0, 1, 2], [3, 0, 2, 1], =
[3, 1, 0, 2], [3, 1, 2, 0], [3, 2, 0, 1], [3, 2, 1, 0]]
>=20
>=20
> [0,1,2,3,4][1,4] =1B$B$O=1B(B [1, 2, 3, 4] =
=1B$B$J$N$G=1B(B0=1B$B$O4^$^$l$J$$$O$:$G$9!%=1B(B
>=20
>=20
> % ./ruby_head -e "p [0,1,2,3][1,3].permutation.to_a"
> =1B$B$@$H@5$7$/F0$-$^$9=1B(B


ary_make_shared =1B$B4X?t$r0J2<$N$h$&$K=3D$@5$9$k$H@5>o$KF0:n$7$^$9!#=1B(B=


diff --git a/array.c b/array.c
index 51d3ad2..ea4fe43 100644
--- a/array.c
+++ b/array.c
@@ -409,10 +409,7 @@ static VALUE
 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)) {
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index e8edcc2..f2d723f 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1549,6 +1549,9 @@ class TestArray < Test::Unit::TestCase
     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 =3D '[ruby-dev:42067]'
+    assert_equal(b, @cls[0, 1, 2, 3, 4][1, 4].permutation.to_a, =
bug3708)
   end
=20
   def test_repeated_permutation


--
Kenta Murata
OpenPGP FP =3D 1D69 ADDE 081C 9CC2 2E54  98C1 CEFE 8AFB 6081 B062

=1B$BK\$r=3Dq$-$^$7$?=1B(B!!
=1B$B!X=1B(BRuby =1B$B5U0z$-%l%7%T!Y=1B(B =
http://www.amazon.co.jp/dp/4798119881/mrkn-22

E-mail: mrkn@mrkn.jp
twitter: http://twitter.com/mrkn/
blog: http://d.hatena.ne.jp/mrkn/=

In This Thread