cvs: php-src /ext/standard math.c /ext/standard/tests/math bug28228.phpt

From: Date: Fri, 30 Apr 2004 13:26:01 +0000
Subject: cvs: php-src /ext/standard math.c /ext/standard/tests/math bug28228.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-27232@lists.php.net to get a copy of this message
iliaa Fri Apr 30 09:26:01 2004 EDT Added files: /php-src/ext/standard/tests/math bug28228.phpt Modified files: /php-src/ext/standard math.c Log: Fixed bug #28228 (number_format() does not allow empty decimal separator). http://cvs.php.net/diff.php/php-src/ext/standard/math.c?r1=1.112&r2=1.113&ty=u Index: php-src/ext/standard/math.c diff -u php-src/ext/standard/math.c:1.112 php-src/ext/standard/math.c:1.113 --- php-src/ext/standard/math.c:1.112 Wed Mar 10 10:59:50 2004 +++ php-src/ext/standard/math.c Fri Apr 30 09:26:01 2004 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: math.c,v 1.112 2004/03/10 15:59:50 abies Exp $ */ +/* $Id: math.c,v 1.113 2004/04/30 13:26:01 iliaa Exp $ */ #include "php.h" #include "php_math.h" @@ -1020,7 +1020,12 @@ is_negative = 1; d = -d; } - dec = MAX(0, dec); + if (!dec_point && dec > 0) { + d *= pow(10, dec); + dec = 0; + } else { + dec = MAX(0, dec); + } PHP_ROUND_WITH_FUZZ(d, dec); @@ -1140,6 +1145,8 @@ convert_to_string_ex(t_s); if (Z_STRLEN_PP(d_p)==1) { dec_point=Z_STRVAL_PP(d_p)[0]; + } else if (Z_STRLEN_PP(d_p)==0) { + dec_point=0; } if (Z_STRLEN_PP(t_s)==1) { thousand_sep=Z_STRVAL_PP(t_s)[0]; http://cvs.php.net/co.php/php-src/ext/standard/tests/math/bug28228.phpt?r=1.1&p=1 Index: php-src/ext/standard/tests/math/bug28228.phpt +++ php-src/ext/standard/tests/math/bug28228.phpt --TEST-- Bug #28228 (number_format() does not allow empty decimal separator) --FILE-- <?php echo number_format(1234.5678, 4, '', '') . "\n"; echo number_format(1234.5678, 4, NULL, ',') . "\n"; echo number_format(1234.5678, 4, 0, ',') . "\n"; echo number_format(1234.5678, 4); ?> --EXPECT-- 12345678 12,345,678 1,23405678 1,234.5678

« previous php.cvs (#27232) next »