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

ruby-changes:17075

From: naruse <ko1@a...>
Date: Mon, 23 Aug 2010 12:20:10 +0900 (JST)
Subject: [ruby-changes:17075] Ruby:r29073 (trunk): * util.c (ruby_strtod): make sure to have digit-sequence after 'p'

naruse	2010-08-23 12:19:58 +0900 (Mon, 23 Aug 2010)

  New Revision: 29073

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

  Log:
    * util.c (ruby_strtod): make sure to have digit-sequence after 'p'
      for hexadecimal-floating-constant. [ruby-dev:42105]

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_float.rb
    trunk/util.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 29072)
+++ ChangeLog	(revision 29073)
@@ -1,3 +1,8 @@
+Mon Aug 23 02:23:05 2010  NARUSE, Yui  <naruse@r...>
+
+	* util.c (ruby_strtod): make sure to have digit-sequence after 'p'
+	  for hexadecimal-floating-constant. [ruby-dev:42105]
+
 Mon Aug 23 00:23:07 2010  Tadayoshi Funaba  <tadf@d...>
 
 	* lib/date.rb, lib/date/format.rb: [ruby-core:31695]
Index: util.c
===================================================================
--- util.c	(revision 29072)
+++ util.c	(revision 29073)
@@ -2141,11 +2141,15 @@
 		if (abs(dsign) == 1) s++;
 		else dsign = 1;
 
-		for (nd = 0; (c = *s) >= '0' && c <= '9'; s++) {
+               nd = 0;
+               c = *s;
+               if (c < '0' || '9' < c) goto ret0;
+               do {
 		    nd *= 10;
 		    nd += c;
 		    nd -= '0';
-		}
+                   c = *++s;
+               } while ('0' <= c && c <= '9');
 		dval(rv) = ldexp(adj, nd * dsign);
 	    }
 	    else {
Index: test/ruby/test_float.rb
===================================================================
--- test/ruby/test_float.rb	(revision 29072)
+++ test/ruby/test_float.rb	(revision 29073)
@@ -446,6 +446,8 @@
     assert_equal(1, suppress_warning {Float(([1] * 10000).join)}.infinite?)
     assert(!Float(([1] * 10000).join("_")).infinite?) # is it really OK?
     assert_raise(ArgumentError) { Float("1.0\x001") }
+    assert_equal(15.9375, Float('0xf.fp0'))
+    assert_raise(ArgumentError) { Float('0xf.fp') }
     assert_equal(1, suppress_warning {Float("1e10_00")}.infinite?)
     assert_raise(TypeError) { Float(nil) }
     o = Object.new

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

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