summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-05 11:06:06 +0100
committerAnatol Belski <ab@php.net>2014-12-05 11:06:06 +0100
commit7943f944c2646f71daf5feb9a0d2f84ec368c1c5 (patch)
tree0896e45b976ffb7a8090ce31ba29b9b2638953d6
parent1e40b0aff6b3ddb998b26e418fa63ce77d4fc4ab (diff)
downloadphp-git-7943f944c2646f71daf5feb9a0d2f84ec368c1c5.tar.gz
Fixed bug #65769 localeconv() broken in TS builds
-rw-r--r--NEWS1
-rw-r--r--ext/standard/string.c10
-rw-r--r--ext/standard/tests/strings/bug65769.phpt80
3 files changed, 91 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index 73b90f85f3..c0f1739e1c 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PHP NEWS
. Fixed bug #55541 (errors spawn MessageBox, which blocks test automation).
(Anatol)
. Fixed bug #68297 (Application Popup provides too few information). (Anatol)
+ . Fixed bug #65769 (localeconv() broken in TS builds). (Anatol)
- cURL:
. Fixed bug #67643 (curl_multi_getcontent returns '' when
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 62122cf1dc..3581e7c6c5 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -203,8 +203,18 @@ PHPAPI struct lconv *localeconv_r(struct lconv *out)
tsrm_mutex_lock( locale_mutex );
# endif
+#if defined(PHP_WIN32) && defined(ZTS)
+ {
+ /* Even with the enabled per thread locale, localeconv
+ won't check any locale change in the master thread. */
+ _locale_t cur = _get_current_locale();
+
+ res = cur->locinfo->lconv;
+ }
+#else
/* localeconv doesn't return an error condition */
res = localeconv();
+#endif
*out = *res;
diff --git a/ext/standard/tests/strings/bug65769.phpt b/ext/standard/tests/strings/bug65769.phpt
new file mode 100644
index 0000000000..15dad45bd5
--- /dev/null
+++ b/ext/standard/tests/strings/bug65769.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Bug #65769 localeconv() broken in TS builds
+--SKIPIF--
+<?php
+if (substr(PHP_OS, 0, 3) != 'WIN') {
+ die('skip Windows only');
+}
+?>
+--FILE--
+<?php
+
+$locales = array('sve', 'french', 'us', 'ru', 'czech', 'serbian');
+
+foreach ($locales as $locale) {
+ $locale = setlocale(LC_ALL, $locale);
+ $lconv = localeconv();
+ var_dump(
+ $locale,
+ $lconv['decimal_point'],
+ $lconv['thousands_sep'],
+ $lconv['int_curr_symbol'],
+ $lconv['currency_symbol'],
+ $lconv['mon_decimal_point'],
+ $lconv['mon_thousands_sep']
+ );
+ echo '++++++++++++++++++++++', "\n";
+}
+
+?>
++++DONE+++
+--EXPECTF--
+string(19) "Swedish_Sweden.1252"
+string(1) ","
+string(1) " "
+string(3) "SEK"
+string(2) "kr"
+string(1) ","
+string(1) "."
+++++++++++++++++++++++
+string(18) "French_France.1252"
+string(1) ","
+string(1) " "
+string(3) "EUR"
+string(1) "€"
+string(1) ","
+string(1) " "
+++++++++++++++++++++++
+string(26) "English_United States.1252"
+string(1) "."
+string(1) ","
+string(3) "USD"
+string(1) "$"
+string(1) "."
+string(1) ","
+++++++++++++++++++++++
+string(2) "ru"
+string(1) ","
+string(1) " "
+string(3) "RUB"
+string(1) "?"
+string(1) ","
+string(1) " "
+++++++++++++++++++++++
+string(25) "Czech_Czech Republic.1250"
+string(1) ","
+string(1) " "
+string(3) "CZK"
+string(2) "Kč"
+string(1) ","
+string(1) " "
+++++++++++++++++++++++
+string(19) "Serbian_Serbia.1250"
+string(1) ","
+string(1) "."
+string(3) "RSD"
+string(4) "din."
+string(1) ","
+string(1) "."
+++++++++++++++++++++++
++++DONE+++