From 3eadc2ad5856e7256b5cc156c78fee192889e9a2 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Fri, 22 Dec 2006 04:03:35 +0000 Subject: [PATCH] MFB: Fixed bug #39873 (number_format() breaks with locale & decimal points). --- ext/standard/math.c | 6 +++++- ext/standard/tests/strings/bug39873.phpt | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/strings/bug39873.phpt diff --git a/ext/standard/math.c b/ext/standard/math.c index f1a6809b48..16b93dac54 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -929,7 +929,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.40.0