mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
unsigned seed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cabeaac37b
commit
cd2af215d4
1 changed files with 6 additions and 6 deletions
12
random.c
12
random.c
|
@ -87,11 +87,11 @@ rb_f_srand(argc, argv, obj)
|
||||||
VALUE *argv;
|
VALUE *argv;
|
||||||
VALUE obj;
|
VALUE obj;
|
||||||
{
|
{
|
||||||
VALUE seed;
|
VALUE a;
|
||||||
int old;
|
unsigned int seed, old;
|
||||||
static int saved_seed;
|
static unsigned int saved_seed;
|
||||||
|
|
||||||
if (rb_scan_args(argc, argv, "01", &seed) == 0) {
|
if (rb_scan_args(argc, argv, "01", &a) == 0) {
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ rb_f_srand(argc, argv, obj)
|
||||||
seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
|
seed = tv.tv_sec ^ tv.tv_usec ^ getpid() ^ n++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
seed = NUM2UINT(seed);
|
seed = NUM2UINT(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_RANDOM
|
#ifdef HAVE_RANDOM
|
||||||
|
@ -116,7 +116,7 @@ rb_f_srand(argc, argv, obj)
|
||||||
old = saved_seed;
|
old = saved_seed;
|
||||||
saved_seed = seed;
|
saved_seed = seed;
|
||||||
|
|
||||||
return rb_int2inum(old);
|
return rb_uint2inum(old);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
|
Loading…
Reference in a new issue