ruby-changes:11582
From: yugui <ko1@a...>
Date: Sun, 19 Apr 2009 22:34:13 +0900 (JST)
Subject: [ruby-changes:11582] Ruby:r23219 (ruby_1_9_1): merges r22992 from trunk into ruby_1_9_1.
yugui 2009-04-19 22:33:31 +0900 (Sun, 19 Apr 2009) New Revision: 23219 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23219 Log: 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] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/enumerator.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 23218) +++ ruby_1_9_1/ChangeLog (revision 23219) @@ -1,3 +1,9 @@ +Tue Mar 17 18:00:55 2009 Akinori MUSHA <knu@i...> + + * 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] + Tue Mar 17 14:25:16 2009 Tanaka Akira <akr@f...> * lib/pathname.rb (Pathname#sub): set $~ in block.binding. Index: ruby_1_9_1/enumerator.c =================================================================== --- ruby_1_9_1/enumerator.c (revision 23218) +++ ruby_1_9_1/enumerator.c (revision 23219) @@ -397,11 +397,17 @@ } 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 @@ } 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); } /* -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/