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

ruby-changes:6355

From: usa <ko1@a...>
Date: Fri, 4 Jul 2008 17:54:59 +0900 (JST)
Subject: [ruby-changes:6355] Ruby:r17871 (ruby_1_8): * numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.

usa	2008-07-04 17:54:47 +0900 (Fri, 04 Jul 2008)

  New Revision: 17871

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/numeric.c

  Log:
    * numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.
    


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

Index: ruby_1_8/numeric.c
===================================================================
--- ruby_1_8/numeric.c	(revision 17870)
+++ ruby_1_8/numeric.c	(revision 17871)
@@ -1600,12 +1600,11 @@
 }
 
 static void
-check_uint(num, sign)
+check_uint(num)
     unsigned long num;
-    int sign;
 {
     if (num > UINT_MAX) {
-	rb_raise(rb_eRangeError, "integer %lu too %s to convert to `unsigned int'", num, sign ? "small" : "big");
+	rb_raise(rb_eRangeError, "integer %"PRIuVALUE " too big to convert to `unsigned int'", num);
     }
 }
 
@@ -1635,7 +1634,10 @@
 {
     unsigned long num = rb_num2ulong(val);
 
-    check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
+    if (RTEST(rb_funcall(val, '<', 1, INT2FIX(0))))
+	check_int(num);
+    else
+	check_uint(num);
     return num;
 }
 
@@ -1649,7 +1651,10 @@
         return rb_num2uint(val);
     }
     num = FIX2ULONG(val);
-    check_uint(num, RTEST(rb_funcall(val, '<', 1, INT2FIX(0))));
+    if (RTEST(rb_funcall(val, '<', 1, INT2FIX(0))))
+	check_int(num);
+    else
+	check_uint(num);
     return num;
 }
 #else
Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 17870)
+++ ruby_1_8/ChangeLog	(revision 17871)
@@ -1,3 +1,7 @@
+Fri Jul  4 17:53:29 2008  NAKAMURA Usaku  <usa@r...>
+
+	* numeric.c (check_uint, rb_num2uint, rb_fix2uint): proper check.
+
 Fri Jul  4 14:17:22 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/net/ftp.rb (Net::FTP#sendport): use divmod.  [ruby-core:17557]

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

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