summaryrefslogtreecommitdiff
path: root/random.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-09 03:52:09 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-09 03:52:09 (GMT)
commitad949e8f31ac43a1805716dfb6382bbdaa0d9ec1 (patch)
tree94677e7dffeb59aabd9351203564d67fe14b0336 /random.c
parent639bfd6d9c52ba7b5371986af8a3329c46bd62a1 (diff)
random.c: seed conversion
* random.c (rand_init): random_seed() always returns an Integer, no conversion for it. * random.c (random_init, rb_f_srand): convert the given seed to an Integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'random.c')
-rw-r--r--random.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/random.c b/random.c
index cff5ea8..b5f6c18 100644
--- a/random.c
+++ b/random.c
@@ -368,8 +368,6 @@ rand_init(struct MT *mt, VALUE seed)
size_t len;
int sign;
- seed = rb_to_int(seed);
-
len = rb_absint_numwords(seed, 32, NULL);
if (len > numberof(buf0))
buf = ALLOC_N(uint32_t, len);
@@ -415,6 +413,7 @@ random_init(int argc, VALUE *argv, VALUE obj)
else {
vseed = argv[0];
rb_check_copyable(obj, vseed);
+ vseed = rb_to_int(vseed);
}
rnd->seed = rand_init(&rnd->mt, vseed);
return obj;
@@ -784,7 +783,7 @@ rb_f_srand(int argc, VALUE *argv, VALUE obj)
seed = random_seed();
}
else {
- seed = argv[0];
+ seed = rb_to_int(argv[0]);
}
old = r->seed;
r->seed = rand_init(&r->mt, seed);