Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
merge revision(s) 18509:
Browse files Browse the repository at this point in the history
	* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8_7@21617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
shyouhei committed Jan 17, 2009
1 parent 68f04c7 commit ce50065
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
Sat Jan 17 12:16:10 2009 Yukihiro Matsumoto <matz@ruby-lang.org>

* random.c (Init_Random): always initialize seed.

Fri Jan 16 10:59:31 2009 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Jan 16 10:59:31 2009 Yukihiro Matsumoto <matz@ruby-lang.org>


* class.c (clone_method): should copy cbase in cref as well. * class.c (clone_method): should copy cbase in cref as well.
Expand Down
6 changes: 1 addition & 5 deletions random.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ rb_genrand_real(void)
#include <fcntl.h> #include <fcntl.h>
#endif #endif


static int first = 1;
static VALUE saved_seed = INT2FIX(0); static VALUE saved_seed = INT2FIX(0);


static VALUE static VALUE
Expand Down Expand Up @@ -245,7 +244,6 @@ rand_init(vseed)
len--; len--;
init_by_array(buf, len); init_by_array(buf, len);
} }
first = 0;
old = saved_seed; old = saved_seed;
saved_seed = seed; saved_seed = seed;
free(buf); free(buf);
Expand Down Expand Up @@ -445,9 +443,6 @@ rb_f_rand(argc, argv, obj)
long val, max; long val, max;


rb_scan_args(argc, argv, "01", &vmax); rb_scan_args(argc, argv, "01", &vmax);
if (first) {
rand_init(random_seed());
}
switch (TYPE(vmax)) { switch (TYPE(vmax)) {
case T_FLOAT: case T_FLOAT:
if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) { if (RFLOAT(vmax)->value <= LONG_MAX && RFLOAT(vmax)->value >= LONG_MIN) {
Expand Down Expand Up @@ -498,6 +493,7 @@ rb_f_rand(argc, argv, obj)
void void
Init_Random() Init_Random()
{ {
rand_init(random_seed());
rb_define_global_function("srand", rb_f_srand, -1); rb_define_global_function("srand", rb_f_srand, -1);
rb_define_global_function("rand", rb_f_rand, -1); rb_define_global_function("rand", rb_f_rand, -1);
rb_global_variable(&saved_seed); rb_global_variable(&saved_seed);
Expand Down
8 changes: 4 additions & 4 deletions version.h
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,15 @@
#define RUBY_VERSION "1.8.7" #define RUBY_VERSION "1.8.7"
#define RUBY_RELEASE_DATE "2009-01-16" #define RUBY_RELEASE_DATE "2009-01-17"
#define RUBY_VERSION_CODE 187 #define RUBY_VERSION_CODE 187
#define RUBY_RELEASE_CODE 20090116 #define RUBY_RELEASE_CODE 20090117
#define RUBY_PATCHLEVEL 87 #define RUBY_PATCHLEVEL 88


#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_MINOR 8
#define RUBY_VERSION_TEENY 7 #define RUBY_VERSION_TEENY 7
#define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_YEAR 2009
#define RUBY_RELEASE_MONTH 1 #define RUBY_RELEASE_MONTH 1
#define RUBY_RELEASE_DAY 16 #define RUBY_RELEASE_DAY 17


#ifdef RUBY_EXTERN #ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[]; RUBY_EXTERN const char ruby_version[];
Expand Down

0 comments on commit ce50065

Please sign in to comment.