summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 03:15:36 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-01-17 03:15:36 +0000
commit912904e481ed3390ecaf75d131f719f1617241cf (patch)
treeb57d69a2d0421017e95f23cdddd85ed3fd222e5f
parent09992441540837dc7068bd45f26eb73080386f94 (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_6@21615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--random.c6
-rw-r--r--version.h2
3 files changed, 6 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 6535cbe54e..52ba76c687 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Jan 17 12:13:10 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * random.c (Init_Random): always initialize seed.
+
Sat Jan 17 12:11:06 2009 NAKAMURA Usaku <usa@ruby-lang.org>
* marshal.c (dump_ensure, load_ensure): should return values.
diff --git a/random.c b/random.c
index eb9803af07..4aad42baea 100644
--- a/random.c
+++ b/random.c
@@ -189,7 +189,6 @@ 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);
diff --git a/version.h b/version.h
index acae4e6d76..4e0f83108a 100644
--- a/version.h
+++ b/version.h
@@ -2,7 +2,7 @@
#define RUBY_RELEASE_DATE "2009-01-17"
#define RUBY_VERSION_CODE 186
#define RUBY_RELEASE_CODE 20090117
-#define RUBY_PATCHLEVEL 301
+#define RUBY_PATCHLEVEL 302
#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8