[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

mjs mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:14:56 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f273a9fd060978c2621224c13b34b4cc1662b739
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Dec 15 03:33:10 2002 +0000

            Reviewed by Ken.
    
    	- further corrections to number printing.
    
            * kjs/ustring.cpp:
            (UString::from): Make number printing match the ECMA standard
    	algorithm.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3053 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/JavaScriptCore/ChangeLog b/JavaScriptCore/ChangeLog
index 1c21f03..86af252 100644
--- a/JavaScriptCore/ChangeLog
+++ b/JavaScriptCore/ChangeLog
@@ -1,5 +1,15 @@
 2002-12-14  Maciej Stachowiak  <mjs at apple.com>
 
+        Reviewed by Ken.
+
+	- further corrections to number printing.
+
+        * kjs/ustring.cpp:
+        (UString::from): Make number printing match the ECMA standard
+	algorithm.
+
+2002-12-14  Maciej Stachowiak  <mjs at apple.com>
+
         Reviewed by Dave.
 
 	- fix toString() conversion for numbers less than 1. Negative
diff --git a/JavaScriptCore/ChangeLog-2003-10-25 b/JavaScriptCore/ChangeLog-2003-10-25
index 1c21f03..86af252 100644
--- a/JavaScriptCore/ChangeLog-2003-10-25
+++ b/JavaScriptCore/ChangeLog-2003-10-25
@@ -1,5 +1,15 @@
 2002-12-14  Maciej Stachowiak  <mjs at apple.com>
 
+        Reviewed by Ken.
+
+	- further corrections to number printing.
+
+        * kjs/ustring.cpp:
+        (UString::from): Make number printing match the ECMA standard
+	algorithm.
+
+2002-12-14  Maciej Stachowiak  <mjs at apple.com>
+
         Reviewed by Dave.
 
 	- fix toString() conversion for numbers less than 1. Negative
diff --git a/JavaScriptCore/kjs/ustring.cpp b/JavaScriptCore/kjs/ustring.cpp
index d9b2464..076f217 100644
--- a/JavaScriptCore/kjs/ustring.cpp
+++ b/JavaScriptCore/kjs/ustring.cpp
@@ -336,8 +336,8 @@ UString UString::from(double d)
   char buf[80];
   int decimalPoint;
   int sign;
-
-  char *result = kjs_dtoa(d, 5, 16, &decimalPoint, &sign, NULL);
+  
+  char *result = kjs_dtoa(d, 0, 0, &decimalPoint, &sign, NULL);
   int length = strlen(result);
   
   int i = 0;
@@ -345,21 +345,55 @@ UString UString::from(double d)
     buf[i++] = '-';
   }
   
-  if (decimalPoint <= 0) {
+  if (decimalPoint <= 0 && decimalPoint > -6) {
     buf[i++] = '0';
     buf[i++] = '.';
     for (int j = decimalPoint; j < 0; j++) {
       buf[i++] = '0';
     }
     strcpy(buf + i, result);
-  } else if (decimalPoint >= length) {
+  } else if (decimalPoint <= 21 && decimalPoint > 0) {
+    if (length <= decimalPoint) {
+      strcpy(buf + i, result);
+      i += length;
+      for (int j = 0; j < decimalPoint - length; j++) {
+	buf[i++] = '0';
+      }
+      buf[i] = '\0';
+    } else {
+      strncpy(buf + i, result, decimalPoint);
+      i += decimalPoint;
+      buf[i++] = '.';
+      strcpy(buf + i, result + decimalPoint);
+    }
+  } else if (result[0] < '0' || result[0] > '9') {
     strcpy(buf + i, result);
   } else {
-    strncpy(buf + i, result, decimalPoint);
-    i += decimalPoint;
-    buf[i++] = '.';
-    strcpy(buf + i, result + decimalPoint);
+    buf[i++] = result[0];
+    if (length > 1) {
+      buf[i++] = '.';
+      strcpy(buf + i, result + 1);
+      i += length - 1;
+    }
+    
+    buf[i++] = 'e';
+    buf[i++] = (decimalPoint >= 0) ? '+' : '-';
+    // decimalPoint can't be more than 3 digits decimal given the
+    // nature of float representation
+    int exponential = decimalPoint - 1;
+    if (exponential < 0) {
+      exponential = exponential * -1;
+    }
+    if (exponential >= 100) {
+      buf[i++] = '0' + exponential / 100;
+    }
+    if (exponential >= 10) {
+      buf[i++] = '0' + (exponential % 100) / 10;
+    }
+    buf[i++] = '0' + exponential % 10;
+    buf[i++] = '\0';
   }
+  
   kjs_freedtoa(result);
   
   return UString(buf);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list