summaryrefslogtreecommitdiffstats
path: root/enumerator.c
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-19 13:33:31 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-04-19 13:33:31 +0000
commitea427bf41b9a97a0b9b9b28b0a16cff7eea99c69 (patch)
tree0cf03ab044e821ebc6de9b2393a7d278de22fea5 /enumerator.c
parentdb738b77beb3a5e09bb035985ebd18663e2395d9 (diff)
merges r22992 from trunk into ruby_1_9_1.
-- * enumerator.c (Enumerator#{each_,}{with_index,with_object}): Fix a bug where any parameter but the first one is dropped even if multiple values are yielded with. [Bug #1198] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@23219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enumerator.c')
-rw-r--r--enumerator.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/enumerator.c b/enumerator.c
index 5dc6eee23..b95280876 100644
--- a/enumerator.c
+++ b/enumerator.c
@@ -397,11 +397,17 @@ enumerator_each(VALUE obj)
}
static VALUE
-enumerator_with_index_i(VALUE val, VALUE *memo)
+enumerator_with_index_i(VALUE val, VALUE *memo, int argc, VALUE *argv)
{
- val = rb_yield_values(2, val, INT2FIX(*memo));
+ VALUE idx;
+
+ idx = INT2FIX(*memo);
++*memo;
- return val;
+
+ if (argc <= 1)
+ return rb_yield_values(2, val, idx);
+
+ return rb_yield_values(2, rb_ary_new4(argc, argv), idx);
}
/*
@@ -432,9 +438,12 @@ enumerator_with_index(VALUE obj)
}
static VALUE
-enumerator_with_object_i(VALUE val, VALUE memo)
+enumerator_with_object_i(VALUE val, VALUE memo, int argc, VALUE *argv)
{
- return rb_yield_values(2, val, memo);
+ if (argc <= 1)
+ return rb_yield_values(2, val, memo);
+
+ return rb_yield_values(2, rb_ary_new4(argc, argv), memo);
}
/*