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

ruby-changes:31697

From: usa <ko1@a...>
Date: Fri, 22 Nov 2013 12:51:18 +0900 (JST)
Subject: [ruby-changes:31697] usa:r43776 (ruby_1_9_3): merge revision(s) 43775:

usa	2013-11-22 12:51:11 +0900 (Fri, 22 Nov 2013)

  New Revision: 43776

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

  Log:
    merge revision(s) 43775:
    
    * util.c (ruby_strtod): ignore too long fraction part, which does not
      affect the result.

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/test/ruby/test_float.rb
    branches/ruby_1_9_3/util.c
    branches/ruby_1_9_3/version.h
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 43775)
+++ ruby_1_9_3/ChangeLog	(revision 43776)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Fri Nov 22 12:44:56 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* util.c (ruby_strtod): ignore too long fraction part, which does not
+	  affect the result.
+
 Fri Nov  1 00:08:21 2013  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* test/openssl/test_pkey_ec.rb: Skip tests for "Oakley" curves as
Index: ruby_1_9_3/util.c
===================================================================
--- ruby_1_9_3/util.c	(revision 43775)
+++ ruby_1_9_3/util.c	(revision 43776)
@@ -674,6 +674,11 @@ extern void *MALLOC(size_t); https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/util.c#L674
 #else
 #define MALLOC malloc
 #endif
+#ifdef FREE
+extern void FREE(void*);
+#else
+#define FREE free
+#endif
 
 #ifndef Omit_Private_Memory
 #ifndef PRIVATE_MEM
@@ -964,7 +969,7 @@ Balloc(int k) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/util.c#L969
 #endif
 
     ACQUIRE_DTOA_LOCK(0);
-    if ((rv = freelist[k]) != 0) {
+    if (k <= Kmax && (rv = freelist[k]) != 0) {
         freelist[k] = rv->next;
     }
     else {
@@ -974,7 +979,7 @@ Balloc(int k) https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/util.c#L979
 #else
         len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1)
                 /sizeof(double);
-        if (pmem_next - private_mem + len <= PRIVATE_mem) {
+        if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) {
             rv = (Bigint*)pmem_next;
             pmem_next += len;
         }
@@ -993,6 +998,10 @@ static void https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/util.c#L998
 Bfree(Bigint *v)
 {
     if (v) {
+        if (v->k > Kmax) {
+            FREE(v);
+            return;
+        }
         ACQUIRE_DTOA_LOCK(0);
         v->next = freelist[v->k];
         freelist[v->k] = v;
@@ -2053,6 +2062,7 @@ break2: https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/util.c#L2062
         for (; c >= '0' && c <= '9'; c = *++s) {
 have_dig:
             nz++;
+            if (nf > DBL_DIG * 2) continue;
             if (c -= '0') {
                 nf += nz;
                 for (i = 1; i < nz; i++)
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 43775)
+++ ruby_1_9_3/version.h	(revision 43776)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 482
+#define RUBY_PATCHLEVEL 483
 
-#define RUBY_RELEASE_DATE "2013-11-01"
+#define RUBY_RELEASE_DATE "2013-11-22"
 #define RUBY_RELEASE_YEAR 2013
 #define RUBY_RELEASE_MONTH 11
-#define RUBY_RELEASE_DAY 1
+#define RUBY_RELEASE_DAY 22
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_float.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_float.rb	(revision 43775)
+++ ruby_1_9_3/test/ruby/test_float.rb	(revision 43776)
@@ -519,4 +519,16 @@ class TestFloat < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_float.rb#L519
       sleep(0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1)
     end
   end
+
+  def test_long_string
+    assert_normal_exit(<<-'end;')
+    assert_in_epsilon(10.0, ("1."+"1"*300000).to_f*9)
+    end;
+  end
+
+  def test_long_string
+    assert_normal_exit(<<-'end;')
+    assert_in_epsilon(10.0, ("1."+"1"*300000).to_f*9)
+    end;
+  end
 end

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

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