[prev in list] [next in list] [prev in thread] [next in thread]
List: php-cvs
Subject: [PHP-CVS] cvs: php-src(PHP_4_3) / NEWS /ext/standard math.c /ext/standard/tests/math bug28228.phpt
From: "Ilia Alshanetsky" <iliaa () php ! net>
Date: 2004-04-30 13:26:06
Message-ID: cvsiliaa1083331566 () cvsserver
[Download RAW message or body]
iliaa Fri Apr 30 09:26:06 2004 EDT
Added files: (Branch: PHP_4_3)
/php-src/ext/standard/tests/math bug28228.phpt
Modified files:
/php-src NEWS
/php-src/ext/standard math.c
Log:
MFH: Fixed bug #28228 (number_format() does not allow empty decimal
separator).
http://cvs.php.net/diff.php/php-src/NEWS?r1=1.1247.2.651&r2=1.1247.2.652&ty=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.1247.2.651 php-src/NEWS:1.1247.2.652
--- php-src/NEWS:1.1247.2.651 Thu Apr 29 12:25:54 2004
+++ php-src/NEWS Fri Apr 30 09:26:05 2004
@@ -5,6 +5,8 @@
then 1 character long. (Ilia)
- Fixed handling of return values from storred procedures in mssql_execute()
with multiple result sets returned. (Frank)
+- Fixed bug #28228 (number_format() does not allow empty decimal separator).
+ (Ilia)
- Fixed bug #28196 (missing error constants in cURL extension). (Ilia)
- Fixed bug #28187 (parse_url() not handling embedded IPv6 in URLs). (Sara)
- Fixed bug #28147 (Crash with drawing anti-aliased lines). (Derick)
http://cvs.php.net/diff.php/php-src/ext/standard/math.c?r1=1.97.2.9&r2=1.97.2.10&ty=u
Index: php-src/ext/standard/math.c
diff -u php-src/ext/standard/math.c:1.97.2.9 php-src/ext/standard/math.c:1.97.2.10
--- php-src/ext/standard/math.c:1.97.2.9 Fri Mar 26 15:01:53 2004
+++ php-src/ext/standard/math.c Fri Apr 30 09:26:06 2004
@@ -19,7 +19,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: math.c,v 1.97.2.9 2004/03/26 20:01:53 abies Exp $ */
+/* $Id: math.c,v 1.97.2.10 2004/04/30 13:26:06 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
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic