From: Marcus Boerger Date: Fri, 8 Aug 2003 20:23:07 +0000 (+0000) Subject: Bugfix #24063 X-Git-Tag: php-4.3.3RC4~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd6bd53646f8d830ca670369740679388a2723f0;p=php Bugfix #24063 --- diff --git a/NEWS b/NEWS index 8d1104c8be..4269cf95e2 100644 --- 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) diff --git a/main/snprintf.c b/main/snprintf.c index 4915c23cc9..8aa2d01881 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -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';