* enum.c (first_i): wrong condition for no argument #first.
[ruby-core:24017] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c6480cd096
commit
304c060d4a
@ -1,3 +1,8 @@
|
|||||||
|
Thu Jun 25 06:25:49 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* enum.c (first_i): wrong condition for no argument #first.
|
||||||
|
[ruby-core:24017]
|
||||||
|
|
||||||
Wed Jun 24 20:19:11 2009 Tanaka Akira <akr@fsij.org>
|
Wed Jun 24 20:19:11 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* time.c (time_s_now): new function. Time.now don't take arguments.
|
* time.c (time_s_now): new function. Time.now don't take arguments.
|
||||||
|
24
enum.c
24
enum.c
@ -608,23 +608,23 @@ enum_group_by(VALUE obj)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
first_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
|
first_i(VALUE i, VALUE *params, int argc, VALUE *argv)
|
||||||
{
|
{
|
||||||
ENUM_WANT_SVALUE();
|
ENUM_WANT_SVALUE();
|
||||||
|
|
||||||
if (NIL_P(ary[0])) {
|
if (NIL_P(params[1])) {
|
||||||
ary[1] = i;
|
params[1] = i;
|
||||||
rb_iter_break();
|
rb_iter_break();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
long n = ary[0];
|
long n = params[0];
|
||||||
|
|
||||||
rb_ary_push(ary[1], i);
|
rb_ary_push(params[1], i);
|
||||||
n--;
|
n--;
|
||||||
if (n <= 0) {
|
if (n <= 0) {
|
||||||
rb_iter_break();
|
rb_iter_break();
|
||||||
}
|
}
|
||||||
ary[0] = n;
|
params[0] = n;
|
||||||
}
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
@ -643,10 +643,10 @@ first_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
|
|||||||
static VALUE
|
static VALUE
|
||||||
enum_first(int argc, VALUE *argv, VALUE obj)
|
enum_first(int argc, VALUE *argv, VALUE obj)
|
||||||
{
|
{
|
||||||
VALUE n, ary[2];
|
VALUE n, params[2];
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
ary[0] = ary[1] = Qnil;
|
params[0] = params[1] = Qnil;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
long len;
|
long len;
|
||||||
@ -657,12 +657,12 @@ enum_first(int argc, VALUE *argv, VALUE obj)
|
|||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
rb_raise(rb_eArgError, "negative length");
|
rb_raise(rb_eArgError, "negative length");
|
||||||
}
|
}
|
||||||
ary[0] = len;
|
params[0] = len;
|
||||||
ary[1] = rb_ary_new2(len);
|
params[1] = rb_ary_new2(len);
|
||||||
}
|
}
|
||||||
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)ary);
|
rb_block_call(obj, id_each, 0, 0, first_i, (VALUE)params);
|
||||||
|
|
||||||
return ary[1];
|
return params[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user