iliaa           Fri Dec 22 04:03:35 2006 UTC

  Modified files:              
    /php-src/ext/standard       math.c 
    /php-src/ext/standard/tests/strings bug39873.phpt 
  Log:
  MFB: Fixed bug #39873 (number_format() breaks with locale & decimal points). 
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/math.c?r1=1.138&r2=1.139&diff_format=u
Index: php-src/ext/standard/math.c
diff -u php-src/ext/standard/math.c:1.138 php-src/ext/standard/math.c:1.139
--- php-src/ext/standard/math.c:1.138   Mon Sep 25 06:59:02 2006
+++ php-src/ext/standard/math.c Fri Dec 22 04:03:35 2006
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: math.c,v 1.138 2006/09/25 06:59:02 dmitry Exp $ */
+/* $Id: math.c,v 1.139 2006/12/22 04:03:35 iliaa Exp $ */
 
 #include "php.h"
 #include "php_math.h"
@@ -929,7 +929,11 @@
        }
 
        /* find decimal point, if expected */
-       dp = dec ? strchr(tmpbuf, '.') : NULL;
+       if (dec) {
+               dp = strpbrk(tmpbuf, ".,");
+       } else {
+               dp = NULL;
+       }
 
        /* calculate the length of the return buffer */
        if (dp) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/strings/bug39873.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/strings/bug39873.phpt
diff -u /dev/null php-src/ext/standard/tests/strings/bug39873.phpt:1.2
--- /dev/null   Fri Dec 22 04:03:35 2006
+++ php-src/ext/standard/tests/strings/bug39873.phpt    Fri Dec 22 04:03:35 2006
@@ -0,0 +1,17 @@
+--TEST--
+Bug #39873 (number_format() breaks with locale & decimal points)
+--SKIPIF--
+<?php
+if (!setlocale(LC_ALL, 
"ita","it","Italian","it_IT","it_IT.ISO8859-1","it_IT.ISO_8859-1")) {
+        die("skip locale needed for this test is not supported on this 
platform");
+}
+?>
+--FILE--
+<?php
+       setlocale(LC_ALL, 
"ita","it","Italian","it_IT","it_IT.ISO8859-1","it_IT.ISO_8859-1");
+       $num = 0+"1234.56";  
+       echo number_format($num,2);
+       echo "\n";
+?>
+--EXPECT--
+1,234.56

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

Reply via email to