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

ruby-changes:9787

From: matz <ko1@a...>
Date: Mon, 5 Jan 2009 07:37:19 +0900 (JST)
Subject: [ruby-changes:9787] Ruby:r21327 (trunk): * range.c (range_max): max value from ... not defined for non

matz	2009-01-05 07:32:40 +0900 (Mon, 05 Jan 2009)

  New Revision: 21327

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21327

  Log:
    * range.c (range_max): max value from ... not defined for non
      Integer Numeric end values. [ruby-dev:37690] fix: #974

  Modified files:
    trunk/ChangeLog
    trunk/range.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 21326)
+++ ChangeLog	(revision 21327)
@@ -1,3 +1,8 @@
+Mon Jan  5 06:39:56 2009  Yukihiro Matsumoto  <matz@r...>
+
+	* range.c (range_max): max value from ... not defined for non
+	  Integer Numeric end values. [ruby-dev:37690] fix: #974
+
 Sun Jan  4 22:37:19 2009  Tanaka Akira  <akr@f...>
 
 	* ext/socket/socket.c (rb_getaddrinfo): defined for address lookup without GVL.
Index: range.c
===================================================================
--- range.c	(revision 21326)
+++ range.c	(revision 21327)
@@ -567,14 +567,13 @@
  *     
  */
 
-
 static VALUE
 range_max(VALUE range)
 {
     VALUE e = RANGE_END(range);
-    int ip = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cInteger);
+    int nm = FIXNUM_P(e) || rb_obj_is_kind_of(e, rb_cNumeric);
 
-    if (rb_block_given_p() || (EXCL(range) && !ip)) {
+    if (rb_block_given_p() || (EXCL(range) && !nm)) {
 	return rb_call_super(0, 0);
     }
     else {
@@ -584,6 +583,9 @@
 	if (c > 0)
 	    return Qnil;
 	if (EXCL(range)) {
+	    if (!FIXNUM_P(e) && !rb_obj_is_kind_of(e, rb_cInteger)) {
+		rb_raise(rb_eTypeError, "cannot exclude non Integer end value");
+	    }
 	    if (c == 0) return Qnil;
 	    if (FIXNUM_P(e)) {
 		return LONG2NUM(FIX2LONG(e) - 1);
@@ -594,6 +596,7 @@
     }
 }
 
+
 VALUE
 rb_range_beg_len(VALUE range, long *begp, long *lenp, long len, int err)
 {

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

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