mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
2 changed files with 17 additions and 12 deletions
|
@ -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>
|
||||
|
||||
* 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
|
||||
first_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
|
||||
first_i(VALUE i, VALUE *params, int argc, VALUE *argv)
|
||||
{
|
||||
ENUM_WANT_SVALUE();
|
||||
|
||||
if (NIL_P(ary[0])) {
|
||||
ary[1] = i;
|
||||
if (NIL_P(params[1])) {
|
||||
params[1] = i;
|
||||
rb_iter_break();
|
||||
}
|
||||
else {
|
||||
long n = ary[0];
|
||||
long n = params[0];
|
||||
|
||||
rb_ary_push(ary[1], i);
|
||||
rb_ary_push(params[1], i);
|
||||
n--;
|
||||
if (n <= 0) {
|
||||
rb_iter_break();
|
||||
}
|
||||
ary[0] = n;
|
||||
params[0] = n;
|
||||
}
|
||||
return Qnil;
|
||||
}
|
||||
|
@ -643,10 +643,10 @@ first_i(VALUE i, VALUE *ary, int argc, VALUE *argv)
|
|||
static VALUE
|
||||
enum_first(int argc, VALUE *argv, VALUE obj)
|
||||
{
|
||||
VALUE n, ary[2];
|
||||
VALUE n, params[2];
|
||||
|
||||
if (argc == 0) {
|
||||
ary[0] = ary[1] = Qnil;
|
||||
params[0] = params[1] = Qnil;
|
||||
}
|
||||
else {
|
||||
long len;
|
||||
|
@ -657,12 +657,12 @@ enum_first(int argc, VALUE *argv, VALUE obj)
|
|||
if (len < 0) {
|
||||
rb_raise(rb_eArgError, "negative length");
|
||||
}
|
||||
ary[0] = len;
|
||||
ary[1] = rb_ary_new2(len);
|
||||
params[0] = 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…
Reference in a new issue