summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2006-12-22 04:03:15 +0000
committerIlia Alshanetsky <iliaa@php.net>2006-12-22 04:03:15 +0000
commitfd8f758ecd3b27884b812f5f8a7af06b2d8c5384 (patch)
treec93dcc0e278978a674a7803af23860b1e0821fb2
parented11386c3d625e0981790937b421e3b4534b733c (diff)
downloadphp-git-fd8f758ecd3b27884b812f5f8a7af06b2d8c5384.tar.gz
Fixed bug #39873 (number_format() breaks with locale & decimal points).
-rw-r--r--NEWS2
-rw-r--r--ext/standard/math.c6
-rw-r--r--ext/standard/tests/strings/bug39873.phpt17
3 files changed, 24 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 3244b03285..538ad3226f 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,8 @@ PHP NEWS
- Fixed bug #39903 (Notice message when executing __halt_compiler() more than
once). (Tony)
- Fixed bug #39898 (FILTER_VALIDATE_URL validates \r\n\t etc). (Ilia)
+- Fixed bug #39873 (number_format() breaks with locale & decimal points).
+ (Ilia)
- Fixed bug #39869 (safe_read does not initialize errno).
(michiel at boland dot org, Dmitry)
- Fixed bug #39850 (SplFileObject throws contradictory/wrong error messages
diff --git a/ext/standard/math.c b/ext/standard/math.c
index c9fcee48fb..79a1693868 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -983,7 +983,11 @@ PHPAPI char *_php_math_number_format(double d, int dec, char dec_point, char tho
}
/* 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) {
diff --git a/ext/standard/tests/strings/bug39873.phpt b/ext/standard/tests/strings/bug39873.phpt
new file mode 100644
index 0000000000..e73f3c8516
--- /dev/null
+++ b/ext/standard/tests/strings/bug39873.phpt
@@ -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