зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_delete): Array#delete to return deleted element.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
abef7fa890
Коммит
e605839355
|
@ -70,6 +70,10 @@ Tue Aug 12 14:15:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* ext/dl/cptr.c (rb_dlptr_s_to_ptr): fixed shadowing variable.
|
* ext/dl/cptr.c (rb_dlptr_s_to_ptr): fixed shadowing variable.
|
||||||
|
|
||||||
|
Tue Aug 12 10:25:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_delete): Array#delete to return deleted element.
|
||||||
|
|
||||||
Tue Aug 12 10:18:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Aug 12 10:18:01 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* test/win32ole/test_err_in_callback.rb: do not require 'mkmf'
|
* test/win32ole/test_err_in_callback.rb: do not require 'mkmf'
|
||||||
|
|
8
array.c
8
array.c
|
@ -1747,12 +1747,16 @@ rb_ary_select(VALUE ary)
|
||||||
VALUE
|
VALUE
|
||||||
rb_ary_delete(VALUE ary, VALUE item)
|
rb_ary_delete(VALUE ary, VALUE item)
|
||||||
{
|
{
|
||||||
|
VALUE v = item;
|
||||||
long i1, i2;
|
long i1, i2;
|
||||||
|
|
||||||
for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
|
for (i1 = i2 = 0; i1 < RARRAY_LEN(ary); i1++) {
|
||||||
VALUE e = RARRAY_PTR(ary)[i1];
|
VALUE e = RARRAY_PTR(ary)[i1];
|
||||||
|
|
||||||
if (rb_equal(e, item)) continue;
|
if (rb_equal(e, item)) {
|
||||||
|
v = e;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (i1 != i2) {
|
if (i1 != i2) {
|
||||||
rb_ary_store(ary, i2, e);
|
rb_ary_store(ary, i2, e);
|
||||||
}
|
}
|
||||||
|
@ -1774,7 +1778,7 @@ rb_ary_delete(VALUE ary, VALUE item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return item;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
|
Загрузка…
Ссылка в новой задаче