summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2014-07-07 00:37:24 -0700
committerStanislav Malyshev <stas@php.net>2014-07-07 00:37:59 -0700
commit8ddf9a2dc4f526821b794cc0b6f537d2cc013d27 (patch)
tree622cd0c7ad78435e9e11254bb3616217b0b67e9c
parentc291033469920fa2155b3b1833731a0aa93257c3 (diff)
parent6c8a570a969b262d233350829ead759364a29e82 (diff)
downloadphp-git-8ddf9a2dc4f526821b794cc0b6f537d2cc013d27.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fix bug #67052 (NumberFormatter::parse() resets LC_NUMERIC setting)
-rw-r--r--NEWS4
-rw-r--r--ext/intl/formatter/formatter_parse.c5
-rw-r--r--ext/intl/tests/bug14562.phpt1
-rw-r--r--ext/intl/tests/bug67052.phpt25
4 files changed, 34 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 89bb30a82b..122d7faf25 100644
--- a/NEWS
+++ b/NEWS
@@ -20,6 +20,10 @@ PHP NEWS
- FPM:
. Fixed bug #67531 (syslog cannot be set in pool configuration). (Remi)
+- Intl:
+ . Fixed bug #67052 (NumberFormatter::parse() resets LC_NUMERIC setting).
+ (Stas)
+
- OPCache:
. Fixed bug #67215 (php-cgi work with opcache, may be segmentation fault
happen) (Dmitry, Laruence)
diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c
index 6f3a3a12b5..0c8704d95c 100644
--- a/ext/intl/formatter/formatter_parse.c
+++ b/ext/intl/formatter/formatter_parse.c
@@ -73,7 +73,9 @@ PHP_FUNCTION( numfmt_parse )
}
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
- oldlocale = setlocale(LC_NUMERIC, "C");
+ /* need to copy here since setlocale may change it later */
+ oldlocale = estrdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
#endif
switch(type) {
@@ -100,6 +102,7 @@ PHP_FUNCTION( numfmt_parse )
}
#if ICU_LOCALE_BUG && defined(LC_NUMERIC)
setlocale(LC_NUMERIC, oldlocale);
+ efree(oldlocale);
#endif
if(zposition) {
zval_dtor(zposition);
diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt
index 3256268405..7cf927f7e7 100644
--- a/ext/intl/tests/bug14562.phpt
+++ b/ext/intl/tests/bug14562.phpt
@@ -15,6 +15,7 @@ function ut_main()
setlocale(LC_ALL, $de_locale);
$fmt = new NumberFormatter("de", NumberFormatter::DECIMAL );
$numeric = $fmt->parse("1234,56");
+ setlocale(LC_ALL, "C"); // reset for printing
$res_str .= "$numeric\n";
return $res_str;
}
diff --git a/ext/intl/tests/bug67052.phpt b/ext/intl/tests/bug67052.phpt
new file mode 100644
index 0000000000..59579395dd
--- /dev/null
+++ b/ext/intl/tests/bug67052.phpt
@@ -0,0 +1,25 @@
+--TEST--
+Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+
+function ut_main()
+{
+ setlocale(LC_ALL, 'sl_SI.UTF-8');
+
+ $fmt = new NumberFormatter( 'sl_SI.UTF-8', NumberFormatter::DECIMAL);
+ $num = "1.234.567,891";
+ $res_str = $fmt->parse($num)."\n";
+ $res_str .= setlocale(LC_NUMERIC, 0);
+ return $res_str;
+}
+
+include_once( 'ut_common.inc' );
+ut_run();
+
+?>
+--EXPECT--
+1234567,891
+sl_SI.UTF-8