sniper          Thu Jul 17 21:37:44 2003 EDT

  Modified files:              (Branch: PHP_4_3)
    /php-src/main       snprintf.c 
  Log:
  MFH: Fixed bug #24640 (var_export and var_dump can not output large float). (Marcus)
  
Index: php-src/main/snprintf.c
diff -u php-src/main/snprintf.c:1.17.4.5 php-src/main/snprintf.c:1.17.4.6
--- php-src/main/snprintf.c:1.17.4.5    Sun Jun 29 21:05:02 2003
+++ php-src/main/snprintf.c     Thu Jul 17 21:37:44 2003
@@ -1,3 +1,25 @@
+/*
+  +----------------------------------------------------------------------+
+  | PHP Version 4                                                        |
+  +----------------------------------------------------------------------+
+  | Copyright (c) 1997-2003 The PHP Group                                |
+  +----------------------------------------------------------------------+
+  | This source file is subject to version 2.02 of the PHP license,      |
+  | that is bundled with this package in the file LICENSE, and is        |
+  | available at through the world-wide-web at                           |
+  | http://www.php.net/license/2_02.txt.                                 |
+  | If you did not receive a copy of the PHP license and are unable to   |
+  | obtain it through the world-wide-web, please send a note to          |
+  | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
+  +----------------------------------------------------------------------+
+  | Author:                                                              |
+  +----------------------------------------------------------------------+
+
+  $Id: snprintf.c,v 1.17.4.6 2003/07/18 01:37:44 sniper Exp $ 
+*/
+
+/* $Id: snprintf.c,v 1.17.4.6 2003/07/18 01:37:44 sniper Exp $ */
+
 /* ====================================================================
  * Copyright (c) 1995-1998 The Apache Group.  All rights reserved.
  *
@@ -132,6 +154,8 @@
        return (p);
 }
 
+/* If you change this value then also change bug24640.phpt.
+ */
 #define        NDIG    80
 
 
@@ -271,6 +295,7 @@
 ap_php_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
 {
        register int r2;
+       int mvl;
        double fi, fj;
        register char *p, *p1;
 
@@ -290,9 +315,16 @@
         */
        if (fi != 0) {
                p1 = &buf[NDIG];
-               while (p1 > &buf[0] && fi != 0) {
+               while (fi != 0) {
                        fj = modf(fi / 10, &fi);
-                       *--p1 = (int) ((fj + .03) * 10) + '0';
+                       if (p1 > &buf[0]) {
+                               *--p1 = (int) ((fj + .03) * 10) + '0';
+                       } else {
+                               mvl = NDIG - ndigits;
+                               memmove(&buf[mvl], &buf[0], NDIG-mvl-1);
+                               p1 += mvl;
+                               *--p1 = (int) ((fj + .03) * 10) + '0';
+                       }
                        r2++;
                }
                while (p1 < &buf[NDIG])



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to