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

ruby-changes:3361

From: ko1@a...
Date: 2 Jan 2008 23:53:29 +0900
Subject: [ruby-changes:3361] akr - Ruby:r14854 (trunk): * util.c (ruby_strtoul): "0x", "+" and "-" is not a valid integer.

akr	2008-01-02 23:53:16 +0900 (Wed, 02 Jan 2008)

  New Revision: 14854

  Modified files:
    trunk/ChangeLog
    trunk/util.c

  Log:
    * util.c (ruby_strtoul): "0x", "+" and "-" is not a valid integer.
      end of integer should be just after "0", the beginning, the
      beginning respectively.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14854&r2=14853&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/util.c?r1=14854&r2=14853&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14853)
+++ ChangeLog	(revision 14854)
@@ -1,3 +1,9 @@
+Wed Jan  2 23:50:15 2008  Tanaka Akira  <akr@f...>
+
+	* util.c (ruby_strtoul): "0x", "+" and "-" is not a valid integer.
+	  end of integer should be just after "0", the beginning, the
+	  beginning respectively.
+
 Wed Jan  2 15:23:15 2008  Tanaka Akira  <akr@f...>
 
 	* util.c (ruby_strtoul): locale independent strtoul is implemented to
Index: util.c
===================================================================
--- util.c	(revision 14853)
+++ util.c	(revision 14854)
@@ -117,6 +117,7 @@
     int sign = 0;
     size_t len;
     unsigned long ret;
+    const char *subject_found = str;
 
     if (base == 1 || 36 < base) {
         errno = EINVAL;
@@ -136,6 +137,7 @@
     }
 
     if (str[0] == '0') {
+        subject_found = str+1;
         if (base == 0 || base == 16) {
             if (str[1] == 'x' || str[1] == 'X') {
                 b = 16;
@@ -157,8 +159,11 @@
 
     ret = scan_digits(str, b, &len, &overflow);
 
+    if (0 < len)
+        subject_found = str+len;
+
     if (endptr)
-        *endptr = (char*)(str+len);
+        *endptr = (char*)subject_found;
 
     if (overflow) {
         errno = ERANGE;
@@ -166,7 +171,7 @@
     }
 
     if (sign < 0) {
-        ret = -(long)ret;
+        ret = -ret;
         return ret;
     }
     else {

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

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