ruby-changes:42888
From: nobu <ko1@a...>
Date: Mon, 9 May 2016 11:55:32 +0900 (JST)
Subject: [ruby-changes:42888] nobu:r54962 (trunk): random.c: seed conversion
nobu 2016-05-09 12:52:09 +0900 (Mon, 09 May 2016) New Revision: 54962 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=54962 Log: random.c: seed conversion * random.c (rand_init): random_seed() always returns an Integer, no conversion for it. * random.c (random_init, rb_f_srand): convert the given seed to an Integer. Modified files: trunk/random.c Index: random.c =================================================================== --- random.c (revision 54961) +++ random.c (revision 54962) @@ -368,8 +368,6 @@ rand_init(struct MT *mt, VALUE seed) https://github.com/ruby/ruby/blob/trunk/random.c#L368 size_t len; int sign; - seed = rb_to_int(seed); - len = rb_absint_numwords(seed, 32, NULL); if (len > numberof(buf0)) buf = ALLOC_N(uint32_t, len); @@ -415,6 +413,7 @@ random_init(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/random.c#L413 else { vseed = argv[0]; rb_check_copyable(obj, vseed); + vseed = rb_to_int(vseed); } rnd->seed = rand_init(&rnd->mt, vseed); return obj; @@ -784,7 +783,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/random.c#L783 seed = random_seed(); } else { - seed = argv[0]; + seed = rb_to_int(argv[0]); } old = r->seed; r->seed = rand_init(&r->mt, seed); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/