[前][次][番号順一覧][スレッド一覧]

ruby-changes:5148

From: knu <ko1@a...>
Date: Tue, 27 May 2008 20:19:06 +0900 (JST)
Subject: [ruby-changes:5148] Ruby:r16643 (trunk): * array.c (rb_ary_slice_bang): Return an empty array instead of

knu	2008-05-27 20:18:50 +0900 (Tue, 27 May 2008)

  New Revision: 16643

  Modified files:
    trunk/ChangeLog
    trunk/array.c

  Log:
    * 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.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/array.c?r1=16643&r2=16642&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16643&r2=16642&diff_format=u

Index: array.c
===================================================================
--- array.c	(revision 16642)
+++ array.c	(revision 16643)
@@ -1815,13 +1815,14 @@
 	    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;
     }
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16642)
+++ ChangeLog	(revision 16643)
@@ -1,3 +1,9 @@
+Tue May 27 20:18:30 2008  Akinori MUSHA  <knu@i...>
+
+	* 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@r...>
 
 	* Makefile.in (MKPREP), common.mk, win32/Makefile.sub (prelude.c): get

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]