]> granicus.if.org Git - php/commitdiff
Bugfix #24063
authorMarcus Boerger <helly@php.net>
Fri, 8 Aug 2003 20:23:07 +0000 (20:23 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 8 Aug 2003 20:23:07 +0000 (20:23 +0000)
NEWS
main/snprintf.c

diff --git a/NEWS b/NEWS
index 8d1104c8bee5422ff0f4c6983d128c1d19904329..4269cf95e2d1b0a48dfea6c41e9b53c6fd4c738a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP 4                                                                      NEWS
 - Fixed bug #24792 (--enable-zend-multibyte causes random segfaults with ZTS).
   (fujimoto)
 - Fixed bug #24909 (Bad random numbers with ZTS builds on Solaris). (Ilia)
+- Fixed bug #24063 (serialize() missing 0 after the . on scientific notation).
+  (Marcus, Ilia)
 
 07 Aug 2003, Version 4.3.3RC3
 - Fixed bug #24958 (Incorrect handling of 404s). (Ilia, Justin)
index 4915c23cc9d44787480252b99c6c6a8d8a92f03f..8aa2d0188159a324e3b63ee953f9124c0ef27180 100644 (file)
@@ -315,14 +315,12 @@ ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
                p1 = &buf[NDIG];
                while (fi != 0) {
                        fj = modf(fi / 10, &fi);
-                       if (p1 > &buf[0]) {
-                               *--p1 = (int) ((fj + .03) * 10) + '0';
-                       } else {
+                       if (p1 <= &buf[0]) {
                                mvl = NDIG - ndigits;
                                memmove(&buf[mvl], &buf[0], NDIG-mvl-1);
                                p1 += mvl;
-                               *--p1 = (int) ((fj + .03) * 10) + '0';
                        }
+                       *--p1 = (int) ((fj + .03) * 10) + '0';
                        r2++;
                }
                while (p1 < &buf[NDIG])
@@ -344,9 +342,17 @@ ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
                buf[0] = '\0';
                return (buf);
        }
-       while (p <= p1 && p < &buf[NDIG]) {
+       if (p <= p1 && p < &buf[NDIG]) {
                arg = modf(arg * 10, &fj);
-               *p++ = (int) fj + '0';
+               if ((int)fj==10) {
+                       *p++ = '1';
+                       fj = 0;
+                       *decpt = ++r2;
+               }
+               while (p <= p1 && p < &buf[NDIG]) {
+                       *p++ = (int) fj + '0';
+                       arg = modf(arg * 10, &fj);
+               }
        }
        if (p1 >= &buf[NDIG]) {
                buf[NDIG - 1] = '\0';