mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
random.c: use rb_check_to_int
* random.c (rand_range, rand_random): use rb_check_to_int instead of rb_check_to_integer with the same conversion method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e303494d0
commit
3377db6b32
1 changed files with 2 additions and 2 deletions
4
random.c
4
random.c
|
@ -1170,7 +1170,7 @@ rand_range(VALUE obj, rb_random_t* rnd, VALUE range)
|
||||||
|
|
||||||
if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse)
|
if ((v = vmax = range_values(range, &beg, &end, &excl)) == Qfalse)
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
|
if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_int(vmax), !NIL_P(v))) {
|
||||||
long max;
|
long max;
|
||||||
vmax = v;
|
vmax = v;
|
||||||
v = Qnil;
|
v = Qnil;
|
||||||
|
@ -1293,7 +1293,7 @@ rand_random(int argc, VALUE *argv, VALUE obj, rb_random_t *rnd)
|
||||||
if (NIL_P(vmax)) {
|
if (NIL_P(vmax)) {
|
||||||
v = Qnil;
|
v = Qnil;
|
||||||
}
|
}
|
||||||
else if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_integer(vmax, "to_int"), !NIL_P(v))) {
|
else if (!RB_TYPE_P(vmax, T_FLOAT) && (v = rb_check_to_int(vmax), !NIL_P(v))) {
|
||||||
v = rand_int(obj, rnd, v, 1);
|
v = rand_int(obj, rnd, v, 1);
|
||||||
}
|
}
|
||||||
else if (v = rb_check_to_float(vmax), !NIL_P(v)) {
|
else if (v = rb_check_to_float(vmax), !NIL_P(v)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue