mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* array.c (rb_ary_slice_bang): Return an empty array instead of
nil when pos is valid and len is adjusted from a valid value to zero; caught by RubySpec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0d3d7c3a1c
commit
c3e7816a78
2 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue May 27 20:18:30 2008 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_slice_bang): Return an empty array instead of
|
||||||
|
nil when pos is valid and len is adjusted from a valid value to
|
||||||
|
zero; caught by RubySpec.
|
||||||
|
|
||||||
Tue May 27 19:12:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Tue May 27 19:12:37 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* Makefile.in (MKPREP), common.mk, win32/Makefile.sub (prelude.c): get
|
* Makefile.in (MKPREP), common.mk, win32/Makefile.sub (prelude.c): get
|
||||||
|
|
5
array.c
5
array.c
|
@ -1815,13 +1815,14 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
|
||||||
pos += orig_len;
|
pos += orig_len;
|
||||||
if (pos < 0) return Qnil;
|
if (pos < 0) return Qnil;
|
||||||
}
|
}
|
||||||
else if (orig_len <= pos) return Qnil;
|
else if (orig_len < pos) return Qnil;
|
||||||
if (orig_len < pos + len) {
|
if (orig_len < pos + len) {
|
||||||
len = orig_len - pos;
|
len = orig_len - pos;
|
||||||
}
|
}
|
||||||
|
if (len == 0) return rb_ary_new2(0);
|
||||||
arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
|
arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
|
||||||
RBASIC(arg2)->klass = rb_obj_class(ary);
|
RBASIC(arg2)->klass = rb_obj_class(ary);
|
||||||
rb_ary_splice(ary, pos, len, Qundef); /* Qnil/rb_ary_new2(0) */
|
rb_ary_splice(ary, pos, len, Qundef);
|
||||||
return arg2;
|
return arg2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue