summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 03:18:21 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 03:18:21 +0000
commit0452ea2c330f8839ab85e400b4e588617277efd5 (patch)
tree27d0f045309a6771c6a0dc0f42b8b0c34277fb4a /random.c
parent78c5478af83453c7ef1bdfec001aace7437d9c1b (diff)
merge revision(s) 18509:
* array.c (rb_ary_sample): rename #choice to #sample. in addition, sample takes optional argument, a la #first. * random.c (Init_Random): always initialize seed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@21617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/random.c b/random.c
index ad5558bca9..258b0b2230 100644
--- a/random.c
+++ b/random.c
@@ -189,7 +189,6 @@ rb_genrand_real(void)
#include <fcntl.h>
#endif
-static int first = 1;
static VALUE saved_seed = INT2FIX(0);
static VALUE
@@ -245,7 +244,6 @@ rand_init(vseed)
len--;
init_by_array(buf, len);
}
- first = 0;
old = saved_seed;
saved_seed = seed;
free(buf);
@@ -445,9 +443,6 @@ rb_f_rand(argc, argv, obj)
long val, max;
rb_scan_args(argc, argv, "01", &vmax);
- if (first) {
- rand_init(random_seed());
- }
switch (TYPE(vmax)) {
case T_FLOAT:
if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) {
@@ -498,6 +493,7 @@ rb_f_rand(argc, argv, obj)
void
Init_Random()
{
+ rand_init(random_seed());
rb_define_global_function("srand", rb_f_srand, -1);
rb_define_global_function("rand", rb_f_rand, -1);
rb_global_variable(&saved_seed);