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

ruby-changes:31657

From: akr <ko1@a...>
Date: Wed, 20 Nov 2013 20:05:47 +0900 (JST)
Subject: [ruby-changes:31657] akr:r43736 (trunk): * random.c (rand_init): Make it possible to specify arbitrary array

akr	2013-11-20 20:05:38 +0900 (Wed, 20 Nov 2013)

  New Revision: 43736

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

  Log:
    * random.c (rand_init): Make it possible to specify arbitrary array
      for init_genrand().

  Modified files:
    trunk/ChangeLog
    trunk/random.c
    trunk/test/ruby/test_rand.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43735)
+++ ChangeLog	(revision 43736)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 20 19:45:22 2013  Tanaka Akira  <akr@f...>
+
+	* random.c (rand_init): Make it possible to specify arbitrary array
+	  for init_genrand().
+
 Wed Nov 20 17:34:13 2013  Koichi Sasada  <ko1@a...>
 
 	* parse.y (rb_gc_mark_symbols): set global_symbols.minor_marked only
Index: test/ruby/test_rand.rb
===================================================================
--- test/ruby/test_rand.rb	(revision 43735)
+++ test/ruby/test_rand.rb	(revision 43736)
@@ -177,7 +177,7 @@ class TestRand < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rand.rb#L177
   end
 
   def test_big_seed
-    assert_random_int(%w(1143843490), 0x100000000, 2**1000000-1)
+    assert_random_int(%w(2757555016), 0x100000000, 2**1000000-1)
   end
 
   def test_random_gc
Index: random.c
===================================================================
--- random.c	(revision 43735)
+++ random.c	(revision 43736)
@@ -377,18 +377,12 @@ rand_init(struct MT *mt, VALUE vseed) https://github.com/ruby/ruby/blob/trunk/random.c#L377
     seed = rb_to_int(vseed);
 
     len = rb_absint_numwords(seed, 32, NULL);
-    if (MT_MAX_STATE < len)
-        len = MT_MAX_STATE;
     if (len > numberof(buf0))
         buf = ALLOC_N(unsigned int, len);
     sign = rb_integer_pack(seed, buf, len, sizeof(uint32_t), 0,
         INTEGER_PACK_LSWORD_FIRST|INTEGER_PACK_NATIVE_BYTE_ORDER);
     if (sign < 0)
         sign = -sign;
-    if (sign != 2) { /* not overflow */
-        while (0 < len && buf[len-1] == 0)
-            len--;
-    }
     if (len == 0) {
         buf[0] = 0;
         len = 1;

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

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