ruby-changes:17213
From: naruse <ko1@a...>
Date: Fri, 10 Sep 2010 15:02:26 +0900 (JST)
Subject: [ruby-changes:17213] Ruby:r29212 (trunk): * random.c (rb_genrand_ulong_limited): renamed from
naruse 2010-09-10 14:44:54 +0900 (Fri, 10 Sep 2010) New Revision: 29212 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29212 Log: * random.c (rb_genrand_ulong_limited): renamed from rb_rand_internal and now this is public API. * include/ruby/ruby.h (rb_genrand_ulong_limited): added. * bignum.c (big_sparse_p): use rb_genrand_ulong_limited. Modified files: trunk/ChangeLog trunk/bignum.c trunk/include/ruby/intern.h trunk/random.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 29211) +++ include/ruby/intern.h (revision 29212) @@ -559,6 +559,7 @@ VALUE rb_random_int(VALUE rnd, VALUE max); unsigned int rb_random_int32(VALUE rnd); double rb_random_real(VALUE rnd); +unsigned long rb_genrand_ulong_limited(unsigned long i); /* re.c */ #define rb_memcmp memcmp int rb_memcicmp(const void*,const void*,long); Index: ChangeLog =================================================================== --- ChangeLog (revision 29211) +++ ChangeLog (revision 29212) @@ -1,3 +1,12 @@ +Fri Sep 10 10:33:18 2010 NARUSE, Yui <naruse@r...> + + * random.c (rb_genrand_ulong_limited): renamed from + rb_rand_internal and now this is public API. + + * include/ruby/ruby.h (rb_genrand_ulong_limited): added. + + * bignum.c (big_sparse_p): use rb_genrand_ulong_limited. + Fri Sep 10 13:07:22 2010 NAKAMURA, Hiroshi <nahi@r...> * ext/digest/lib/digest.rb: removed unused exception variable Index: bignum.c =================================================================== --- bignum.c (revision 29211) +++ bignum.c (revision 29212) @@ -2214,11 +2214,10 @@ big_sparse_p(VALUE x) { long c = 0, n = RBIGNUM_LEN(x); - unsigned long rb_rand_internal(unsigned long i); - if ( BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++; - if (c <= 1 && BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++; - if (c <= 1 && BDIGITS(x)[rb_rand_internal(n / 2) + n / 4]) c++; + if ( BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++; + if (c <= 1 && BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++; + if (c <= 1 && BDIGITS(x)[rb_genrand_ulong_limited(n / 2) + n / 4]) c++; return (c <= 1) ? Qtrue : Qfalse; } Index: random.c =================================================================== --- random.c (revision 29211) +++ random.c (revision 29212) @@ -875,11 +875,16 @@ return rb_big_norm((VALUE)val); } +/* + * Returns random unsigned long value in [0, _limit_]. + * + * Note that _limit_ is included, and the range of the argument and the + * return value depends on environments. + */ unsigned long -rb_rand_internal(unsigned long i) +rb_genrand_ulong_limited(unsigned long limit) { - struct MT *mt = default_mt(); - return limited_rand(mt, i); + return limited_rand(default_mt(), limit); } unsigned int -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/