mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 21:49:06 +02:00
* regex.c (re_search): should consider reverse search.
* dir.c (dir_s_chdir): warn only when invoked from multiple threads or block is not given. * object.c (rb_convert_type): should use rb_rescue(), not rb_rescue2(). * range.c (range_init): ditto. * object.c (rb_obj_dup): should free generic_ivar if original owns them. * string.c (rb_str_each_line): should propagate taint mark. * ext/nkf/nkf.c (rb_nkf_kconv): ditto. * eval.c (rb_f_require): revamp for simpler implementation. * file.c (rb_find_file_noext): use String object, instead of passing char* around. * file.c (rb_find_file): ditto. * dln.c (dln_load): should use NSLINKMODULE_OPTION_BINDNOW. * ruby.c (load_file): local variables 'c' remain uninitialized on xflag. * regex.c (re_match): prefetched escaped character too early. * eval.c (rb_call0): add argument check for attr_readers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f4b516777b
commit
03d1c9cd82
18 changed files with 959 additions and 446 deletions
26
array.c
26
array.c
|
@ -726,6 +726,18 @@ rb_ary_clone(ary)
|
|||
return clone;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_ary_dup(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
VALUE dup = rb_ary_new2(RARRAY(ary)->len);
|
||||
|
||||
OBJSETUP(dup, rb_obj_type(ary), T_ARRAY);
|
||||
MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
|
||||
RARRAY(dup)->len = RARRAY(ary)->len;
|
||||
return dup;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
to_ary(ary)
|
||||
VALUE ary;
|
||||
|
@ -973,7 +985,7 @@ static VALUE
|
|||
rb_ary_reverse_m(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
return rb_ary_reverse(rb_obj_dup(ary));
|
||||
return rb_ary_reverse(rb_ary_dup(ary));
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1034,7 +1046,7 @@ VALUE
|
|||
rb_ary_sort(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
ary = rb_obj_dup(ary);
|
||||
ary = rb_ary_dup(ary);
|
||||
rb_ary_sort_bang(ary);
|
||||
return ary;
|
||||
}
|
||||
|
@ -1047,7 +1059,7 @@ rb_ary_collect(ary)
|
|||
VALUE collect;
|
||||
|
||||
if (!rb_block_given_p()) {
|
||||
return rb_obj_dup(ary);
|
||||
return rb_ary_new4(RARRAY(ary)->len, RARRAY(ary)->ptr);
|
||||
}
|
||||
|
||||
len = RARRAY(ary)->len;
|
||||
|
@ -1566,7 +1578,7 @@ static VALUE
|
|||
rb_ary_uniq(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
ary = rb_obj_dup(ary);
|
||||
ary = rb_ary_dup(ary);
|
||||
rb_ary_uniq_bang(ary);
|
||||
return ary;
|
||||
}
|
||||
|
@ -1597,7 +1609,7 @@ static VALUE
|
|||
rb_ary_compact(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
ary = rb_obj_dup(ary);
|
||||
ary = rb_ary_dup(ary);
|
||||
rb_ary_compact_bang(ary);
|
||||
return ary;
|
||||
}
|
||||
|
@ -1675,7 +1687,7 @@ static VALUE
|
|||
rb_ary_flatten(ary)
|
||||
VALUE ary;
|
||||
{
|
||||
ary = rb_obj_dup(ary);
|
||||
ary = rb_ary_dup(ary);
|
||||
rb_ary_flatten_bang(ary);
|
||||
return ary;
|
||||
}
|
||||
|
@ -1724,6 +1736,7 @@ Init_Array()
|
|||
rb_define_method(rb_cArray, "indexes", rb_ary_indexes, -1);
|
||||
rb_define_method(rb_cArray, "indices", rb_ary_indexes, -1);
|
||||
rb_define_method(rb_cArray, "clone", rb_ary_clone, 0);
|
||||
rb_define_method(rb_cArray, "clone", rb_ary_dup, 0);
|
||||
rb_define_method(rb_cArray, "join", rb_ary_join_m, -1);
|
||||
rb_define_method(rb_cArray, "reverse", rb_ary_reverse_m, 0);
|
||||
rb_define_method(rb_cArray, "reverse!", rb_ary_reverse_bang, 0);
|
||||
|
@ -1731,6 +1744,7 @@ Init_Array()
|
|||
rb_define_method(rb_cArray, "sort!", rb_ary_sort_bang, 0);
|
||||
rb_define_method(rb_cArray, "collect", rb_ary_collect, 0);
|
||||
rb_define_method(rb_cArray, "collect!", rb_ary_collect_bang, 0);
|
||||
rb_define_method(rb_cArray, "map", rb_ary_collect, 0);
|
||||
rb_define_method(rb_cArray, "map!", rb_ary_collect_bang, 0);
|
||||
rb_define_method(rb_cArray, "filter", rb_ary_filter, 0);
|
||||
rb_define_method(rb_cArray, "delete", rb_ary_delete, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue