summaryrefslogtreecommitdiff
path: root/main/spprintf.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-06 11:59:43 +0100
committerAnatol Belski <ab@php.net>2014-12-06 11:59:43 +0100
commit1b4d5ad46a60401bb3db754b4ef6888a7285e637 (patch)
tree0f32497547dd60278673d8bfb8ce00c3a7cc8305 /main/spprintf.c
parent625b929c6eb222773d175bd22a7b893165b960fd (diff)
downloadphp-git-1b4d5ad46a60401bb3db754b4ef6888a7285e637.tar.gz
Fixed bug #65230 setting locale randomly broken
Diffstat (limited to 'main/spprintf.c')
-rw-r--r--main/spprintf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/main/spprintf.c b/main/spprintf.c
index 5b16d51441..212914fe9d 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -93,7 +93,11 @@
#ifdef HAVE_LOCALE_H
#include <locale.h>
+#ifdef ZTS
+#define LCONV_DECIMAL_POINT (*lconv.decimal_point)
+#else
#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
+#endif
#else
#define LCONV_DECIMAL_POINT '.'
#endif
@@ -217,8 +221,12 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
char char_buf[2]; /* for printing %% and %<unknown> */
#ifdef HAVE_LOCALE_H
+#ifdef ZTS
+ struct lconv lconv;
+#else
struct lconv *lconv = NULL;
#endif
+#endif
/*
* Flag variables
@@ -608,10 +616,14 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
s_len = 3;
} else {
#ifdef HAVE_LOCALE_H
+#ifdef ZTS
+ localeconv_r(&lconv);
+#else
if (!lconv) {
lconv = localeconv();
}
#endif
+#endif
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
(*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
@@ -664,10 +676,14 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap)
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
#ifdef HAVE_LOCALE_H
+#ifdef ZTS
+ localeconv_r(&lconv);
+#else
if (!lconv) {
lconv = localeconv();
}
#endif
+#endif
s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;