Skip to content

Commit

Permalink
* array.c (rb_ary_collect): must get length of array for each
Browse files Browse the repository at this point in the history
	  iteration. reported on [ruby-talk:77500], and fixed by
	  K.Sasada <[email protected]> on [ruby-talk:77504]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4240 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
unak committed Jul 31, 2003
1 parent 00dfd7d commit 2047c47
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Thu Jul 31 15:25:12 2003 NAKAMURA Usaku <[email protected]>

* array.c (rb_ary_collect): must get length of array for each
iteration. reported on [ruby-talk:77500], and fixed by
K.Sasada <[email protected]> on [ruby-talk:77504]

Thu Jul 31 14:11:54 2003 GOTOU Yuuzou <[email protected]>

* ext/openssl/extconf.rb: move gmake specific features
Expand Down
7 changes: 3 additions & 4 deletions array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1190,16 +1190,15 @@ static VALUE
rb_ary_collect(ary)
VALUE ary;
{
long len, i;
long i;
VALUE collect;

if (!rb_block_given_p()) {
return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
}

len = RARRAY(ary)->len;
collect = rb_ary_new2(len);
for (i=0; i<len; i++) {
collect = rb_ary_new2(RARRAY(ary)->len);
for (i = 0; i < RARRAY(ary)->len; i++) {
rb_ary_push(collect, rb_yield(RARRAY(ary)->ptr[i]));
}
return collect;
Expand Down

0 comments on commit 2047c47

Please sign in to comment.