summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 11:18:50 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-27 11:18:50 +0000
commitc3e7816a7834d7361a2b1f394e6992962f9924f3 (patch)
tree0349edbbc8a3999faab878de860422d65ef8f5e3 /array.c
parent0d3d7c3a1ce7dc4007b5e1b6cd803db137bd04b9 (diff)
* 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
Diffstat (limited to 'array.c')
-rw-r--r--array.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/array.c b/array.c
index 3e8be3f280..5dd172c157 100644
--- a/array.c
+++ b/array.c
@@ -1815,13 +1815,14 @@ rb_ary_slice_bang(int argc, VALUE *argv, VALUE ary)
pos += orig_len;
if (pos < 0) return Qnil;
}
- else if (orig_len <= pos) return Qnil;
+ else if (orig_len < pos) return Qnil;
if (orig_len < pos + len) {
len = orig_len - pos;
}
+ if (len == 0) return rb_ary_new2(0);
arg2 = rb_ary_new4(len, RARRAY_PTR(ary)+pos);
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;
}