summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-02 03:50:53 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-10-02 03:50:53 +0000
commit6f9dcadf6e46c80bb1f807f88a691cfe388f4f8b (patch)
tree5756b304650334db0189529589f40dcd4beae38c /enum.c
parentd57bbd48f8d43b512d171f53edc198d3043d933c (diff)
* string.c (rb_str_sum): check was done with false pointer.
[ruby-dev:24383] * string.c (rb_str_sum): string may be altered. [ruby-dev:24381] * eval.c (rb_f_eval): defer pointer retrieval to prevent unsafe sourcefile string modification. [ruby-dev:24373] * io.c (io_read): block string buffer modification during rb_io_fread() by freezing it temporarily. [ruby-dev:24366] * io.c (rb_io_s_popen): mode argument may be altered. [ruby-dev:24375] * file.c (rb_file_s_basename): ext argument may be altered. [ruby-dev:24377] * enum.c (enum_sort_by): use NODE instead of 2 element arrays. [ruby-dev:24378] * string.c (rb_str_chomp_bang): StringValue() may change the receiver. [ruby-dev:24371] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/enum.c b/enum.c
index 67d6ee8bf3..f72c682107 100644
--- a/enum.c
+++ b/enum.c
@@ -389,26 +389,26 @@ static VALUE
sort_by_i(i, ary)
VALUE i, ary;
{
- VALUE v, e;
+ VALUE v;
+ NODE *memo;
v = rb_yield(i);
- e = rb_assoc_new(v, i);
- OBJ_FREEZE(e);
- rb_ary_push(ary, e);
+ memo = rb_node_newnode(NODE_MEMO, v, i, 0);
+ rb_ary_push(ary, (VALUE)memo);
return Qnil;
}
static VALUE
sort_by_cmp(values, ary)
- VALUE values;
+ VALUE values, ary;
{
- VALUE a = RARRAY(values)->ptr[0];
- VALUE b = RARRAY(values)->ptr[1];
+ NODE *a = (NODE*)RARRAY(values)->ptr[0];
+ NODE *b = (NODE*)RARRAY(values)->ptr[1];
- /* pedantic check; they must be arrays */
- Check_Type(a, T_ARRAY);
- Check_Type(b, T_ARRAY);
- return rb_funcall(RARRAY(a)->ptr[0], id_cmp, 1, RARRAY(b)->ptr[0]);
+ /* pedantic check; they must be memo nodes */
+ Check_Type(a, T_NODE);
+ Check_Type(b, T_NODE);
+ return rb_funcall(a->u1.value, id_cmp, 1, b->u1.value);
}
/*
@@ -498,8 +498,7 @@ enum_sort_by(obj)
rb_iterate(rb_ary_sort_bang, ary, sort_by_cmp, ary);
}
for (i=0; i<RARRAY(ary)->len; i++) {
- VALUE e = RARRAY(ary)->ptr[i];
- RARRAY(ary)->ptr[i] = RARRAY(e)->ptr[1];
+ RARRAY(ary)->ptr[i] = RNODE(RARRAY(ary)->ptr[i])->u2.value;
}
return ary;
}