Project

General

Profile

Bug #1554 » enum_first_187.patch

marcandre (Marc-Andre Lafortune), 06/02/2009 05:38 AM

View differences:

enum.c (working copy)
else {
long n = NUM2LONG(ary[0]);
rb_ary_push(ary[1], i);
n--;
if (n <= 0) {
rb_iter_break();
}
rb_ary_push(ary[1], i);
n--;
ary[0] = INT2NUM(n);
}
return Qnil;
......
ary[0] = ary[1] = Qnil;
}
else {
long len;
rb_scan_args(argc, argv, "01", &n);
ary[0] = n;
ary[1] = rb_ary_new2(NUM2LONG(n));
len = NUM2LONG(n);
if (len == 0) return rb_ary_new2(0);
ary[0] = INT2NUM(len);
ary[1] = rb_ary_new2(len);
}
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
......
VALUE i;
VALUE *arg;
{
if (arg[1]-- == 0) rb_iter_break();
rb_ary_push(arg[0], i);
if (--arg[1] == 0) rb_iter_break();
return Qnil;
}
......
rb_raise(rb_eArgError, "attempt to take negative size");
}
if (len == 0) return rb_ary_new2(0);
args[1] = len;
args[0] = rb_ary_new();
rb_block_call(obj, id_each, 0, 0, take_i, (VALUE)args);
(2-2/2)