Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:24414 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91007 invoked by uid 1010); 16 Jul 2006 10:36:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 90992 invoked from network); 16 Jul 2006 10:36:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2006 10:36:58 -0000 X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 69.179.208.43 msa3-mx.centurytel.net Linux 2.4/2.6 Received: from ([69.179.208.43:59606] helo=msa3-mx.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.3 r(11751M)) with ESMTP id 79/7F-11992-8C61AB44 for ; Sun, 16 Jul 2006 06:36:57 -0400 Received: from pc1 (72-161-145-29.dyn.centurytel.net [72.161.145.29]) by msa3-mx.centurytel.net (8.13.6/8.13.6) with SMTP id k6GAaqLD018961 for ; Sun, 16 Jul 2006 05:36:53 -0500 Message-ID: <00b601c6a8c3$c116e4f0$0201a8c0@pc1> To: Date: Sun, 16 Jul 2006 05:36:53 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: [PATCH] number_format bug fix (29538) From: php_lists@realplain.com ("Matt W") Hi, Here's patches I mentioned a week ago for bug #29538. I happened to notice it while trying to enhance the functionality of number_format(). It's also mentioned at the end of bug #28228. Where number_format(1234, 2, '', ',') returns 123,400 instead of the expected 1,23400 Happens when decimal places is > 0 with an empty decimal separator. There's a test with that criteria, but the thousands separator is also empty, which hides the bug. I also made some small optimizations -- removing a strlen(), etc. -- hope they're OK. Another possible(?) problem in _php_math_number_format was that if no decimal point was found (with dec > 0), s-- would lose the right-most integer digit. That's why it's decremented in the if (dp) { } block now. (dp should exist, I guess, if dec > 0, but the check is already there in case. :-)) Finally, I changed the proto, if that's OK, to match what's in the manual, and be closer to the variable names... And "separator" was spelled wrong anyway. ;-) I don't know if it's too late to fix 4.4.3, but I have the diff for it too. http://realplain.com/php/number_format_bug29538.diff http://realplain.com/php/number_format_bug29538_5_2.diff http://realplain.com/php/number_format_bug29538_4_4.diff And a test file: http://realplain.com/php/bug29538.phpt Thanks, Matt