diff options
| author | Anatol Belski <ab@php.net> | 2014-12-06 11:59:43 +0100 |
|---|---|---|
| committer | Anatol Belski <ab@php.net> | 2014-12-06 11:59:43 +0100 |
| commit | 1b4d5ad46a60401bb3db754b4ef6888a7285e637 (patch) | |
| tree | 0f32497547dd60278673d8bfb8ce00c3a7cc8305 /ext/standard/formatted_print.c | |
| parent | 625b929c6eb222773d175bd22a7b893165b960fd (diff) | |
| download | php-git-1b4d5ad46a60401bb3db754b4ef6888a7285e637.tar.gz | |
Fixed bug #65230 setting locale randomly broken
Diffstat (limited to 'ext/standard/formatted_print.c')
| -rw-r--r-- | ext/standard/formatted_print.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/standard/formatted_print.c b/ext/standard/formatted_print.c index 2592b1655d..a21bfebe42 100644 --- a/ext/standard/formatted_print.c +++ b/ext/standard/formatted_print.c @@ -27,7 +27,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 @@ -214,8 +218,12 @@ php_sprintf_appenddouble(char **buffer, int *pos, char *s = NULL; int s_len = 0, is_negative = 0; #ifdef HAVE_LOCALE_H +#ifdef ZTS + struct lconv lconv; +#else struct lconv *lconv; #endif +#endif PRINTF_DEBUG(("sprintf: appenddouble(%x, %x, %x, %f, %d, '%c', %d, %c)\n", *buffer, pos, size, number, width, padding, alignment, fmt)); @@ -246,8 +254,12 @@ php_sprintf_appenddouble(char **buffer, int *pos, case 'f': case 'F': #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else lconv = localeconv(); #endif +#endif s = php_conv_fp((fmt == 'f')?'F':fmt, number, 0, precision, (fmt == 'f')?LCONV_DECIMAL_POINT:'.', &is_negative, &num_buf[1], &s_len); @@ -270,8 +282,12 @@ php_sprintf_appenddouble(char **buffer, int *pos, * * We use &num_buf[ 1 ], so that we have room for the sign */ #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else lconv = localeconv(); #endif +#endif s = php_gcvt(number, precision, LCONV_DECIMAL_POINT, (fmt == 'G')?'E':'e', &num_buf[1]); is_negative = 0; if (*s == '-') { |
