diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | array.c | 7 |
2 files changed, 10 insertions, 3 deletions
@@ -1,3 +1,9 @@ +Tue May 27 20:19:22 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:45:20 2008 Akinori MUSHA <knu@iDaemons.org> * numeric.c (flo_divmod): Revert the behavior change; do not @@ -2090,18 +2090,19 @@ rb_ary_slice_bang(argc, argv, 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, Qnil); /* Qnil/rb_ary_new2(0) */ + rb_ary_splice(ary, pos, len, Qnil); /* Qundef in 1.9 */ return arg2; } if (!FIXNUM_P(arg1)) { - switch (rb_range_beg_len(arg1, &pos, &len, RARRAY(ary)->len, 0)) { + switch (rb_range_beg_len(arg1, &pos, &len, RARRAY_LEN(ary), 0)) { case Qtrue: /* valid range */ goto delete_pos_len; |