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

ruby-changes:6346

From: usa <ko1@a...>
Date: Fri, 4 Jul 2008 02:22:48 +0900 (JST)
Subject: [ruby-changes:6346] Ruby:r17861 (trunk): * numeric.c (check_uint, rb_num2uint): also needs checking negative

usa	2008-07-04 02:22:29 +0900 (Fri, 04 Jul 2008)

  New Revision: 17861

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c

  Log:
    * numeric.c (check_uint, rb_num2uint): also needs checking negative
      value. see [ruby-dev:33683]
    


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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 17860)
+++ ChangeLog	(revision 17861)
@@ -1,3 +1,8 @@
+Fri Jul  4 02:21:06 2008  NAKAMURA Usaku  <usa@r...>
+
+	* numeric.c (check_uint, rb_num2uint): also needs checking negative
+	  value. see [ruby-dev:33683]
+
 Thu Jul  3 23:26:36 2008  Yusuke Endoh  <mame@t...>
 
 	* include/ruby/intern.h: remove prototypes about coverage.
Index: numeric.c
===================================================================
--- numeric.c	(revision 17860)
+++ numeric.c	(revision 17861)
@@ -1585,10 +1585,10 @@
 }
 
 static void
-check_uint(VALUE num)
+check_uint(VALUE num, int sign)
 {
     if (num > UINT_MAX) {
-	rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num);
+	rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too %s to convert to `unsigned int'", num, sign ? "small" : "big");
     }
 }
 
@@ -1615,9 +1615,7 @@
 {
     unsigned long num = rb_num2ulong(val);
 
-    if (RTEST(rb_funcall(INT2FIX(0), '<', 1, val))) {
-	check_uint(num);
-    }
+    check_uint(num, RTEST(rb_funcall(val, '<', INT2FIX(0))));
     return num;
 }
 
@@ -1630,9 +1628,7 @@
 	return rb_num2uint(val);
     }
     num = FIX2ULONG(val);
-    if (FIX2LONG(val) > 0) {
-	check_uint(num);
-    }
+    check_uint(num, RTEST(rb_funcall(val, '<', INT2FIX(0))));
     return num;
 }
 #else

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

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