]> granicus.if.org Git - php/commitdiff
(php_math_number_format) Simplifying the logic also fixed bugs #4954
authorAndrei Zmievski <andrei@php.net>
Tue, 13 Jun 2000 04:31:02 +0000 (04:31 +0000)
committerAndrei Zmievski <andrei@php.net>
Tue, 13 Jun 2000 04:31:02 +0000 (04:31 +0000)
and #4998.

ext/standard/math.c

index c48fd1c0bbbbd5cf00d9d16e12203ed3d493cea6..26293eb293eb5ab3fcaf284a2d3851e0371020ef 100644 (file)
@@ -636,14 +636,6 @@ char *_php_math_number_format(double d,int dec,char dec_point,char thousand_sep)
                return tmpbuf;
        }
 
-       if (dec_point!='.') {
-               for (t=tmpbuf; *t; t++) {
-                       if (*t=='.') {
-                               *t = dec_point;
-                               break;
-                       }
-               }
-       }
        if (dec) {
                reslen = dec+1 + (tmplen-dec-1) + (tmplen-1-dec-1)/3;
        } else {
@@ -659,10 +651,11 @@ char *_php_math_number_format(double d,int dec,char dec_point,char thousand_sep)
        *t-- = 0;
        
        if (dec) {
-               while (*s!=dec_point) {
+               while (isdigit((int)*s)) {
                        *t-- = *s--;
                }
-               *t-- = *s--;  /* copy that dot */
+               *t-- = dec_point;  /* copy that dot */
+               s--;
        }
        
        while(s>=tmpbuf) {