summaryrefslogtreecommitdiff
path: root/main/snprintf.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-12-06 12:00:17 +0100
committerAnatol Belski <ab@php.net>2014-12-06 12:00:17 +0100
commitebaf130a15758134f9d8225bcf257d544461c5e1 (patch)
tree685eafaeab47fc612a37465da6a49c1d3185ec08 /main/snprintf.c
parentb120f9beb2a0d07c8c16d9e6cc5b1226bb863d31 (diff)
parent1b4d5ad46a60401bb3db754b4ef6888a7285e637 (diff)
downloadphp-git-ebaf130a15758134f9d8225bcf257d544461c5e1.tar.gz
Merge branch 'PHP-5.5' into PHP-5.6
* PHP-5.5: Fixed bug #65230 setting locale randomly broken
Diffstat (limited to 'main/snprintf.c')
-rw-r--r--main/snprintf.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/main/snprintf.c b/main/snprintf.c
index 2a452ef1f3..f42e15a21a 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -38,7 +38,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
@@ -606,8 +610,12 @@ static int format_converter(register buffy * odp, 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
@@ -998,10 +1006,14 @@ static int format_converter(register buffy * odp, 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:'.',
@@ -1055,10 +1067,14 @@ static int format_converter(register buffy * odp, 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++;