From fd8f758ecd3b27884b812f5f8a7af06b2d8c5384 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Fri, 22 Dec 2006 04:03:15 +0000 Subject: [PATCH] Fixed bug #39873 (number_format() breaks with locale & decimal points). --- NEWS | 2 ++ ext/standard/math.c | 6 +++++- ext/standard/tests/strings/bug39873.phpt | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug39873.phpt 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-- + +--FILE-- + +--EXPECT-- +1,234.56 -- 2.50.1