Project

General

Profile

Backport #7903 » random.c.patch

sho-h (Sho Hashimoto), 02/21/2013 10:23 PM

View differences:

random.c (working copy)
VALUE rb_cRandom;
#define id_minus '-'
#define id_plus '+'
static ID id_rand, id_bytes;
static ID id_rand, id_bytes, id_op_lt;
/* :nodoc: */
static void
......
VALUE lim = ULONG2NUM(limit);
VALUE v = rb_funcall2(obj, id_rand, 1, &lim);
unsigned long r = NUM2ULONG(v);
VALUE zero = INT2FIX(0);
if (RTEST(rb_funcall2(v, id_op_lt, 1, &zero))) {
rb_raise(rb_eRangeError, "random number too small %ld", NUM2LONG(v));
}
if (r > limit) {
rb_raise(rb_eRangeError, "random number too big %ld", r);
}
......
id_rand = rb_intern("rand");
id_bytes = rb_intern("bytes");
id_op_lt = rb_intern("<");
}
    (1-1/1)