* array.c (rb_ary_slice_bang): should adjust length before making
sub-array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
646988189a
commit
a7d8042774
@ -1,3 +1,8 @@
|
|||||||
|
Mon May 5 12:12:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* array.c (rb_ary_slice_bang): should adjust length before making
|
||||||
|
sub-array.
|
||||||
|
|
||||||
Mon May 5 11:36:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon May 5 11:36:14 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_dup): should dupe corresponding information.
|
* array.c (rb_ary_dup): should dupe corresponding information.
|
||||||
|
3
array.c
3
array.c
@ -1794,6 +1794,9 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
|
|||||||
pos = RARRAY_LEN(ary) + pos;
|
pos = RARRAY_LEN(ary) + pos;
|
||||||
if (pos < 0) return Qnil;
|
if (pos < 0) return Qnil;
|
||||||
}
|
}
|
||||||
|
if (RARRAY_LEN(ary) < len || RARRAY_LEN(ary) < pos + len) {
|
||||||
|
len = RARRAY_LEN(ary) - pos;
|
||||||
|
}
|
||||||
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); /* Qnil/rb_ary_new2(0) */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user