mirror of
https://github.com/php/php-src.git
synced 2024-11-27 03:44:07 +08:00
Merge branch 'PHP-5.6'
* PHP-5.6: updated NEWS Fixed bug #65230 setting locale randomly broken
This commit is contained in:
commit
3d68d843cb
@ -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
|
||||
@ -211,7 +215,11 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
|
||||
size_t s_len = 0;
|
||||
int 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",
|
||||
@ -243,7 +251,11 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *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:'.',
|
||||
@ -267,7 +279,11 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *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;
|
||||
|
60
ext/standard/tests/strings/bug65230.phpt
Normal file
60
ext/standard/tests/strings/bug65230.phpt
Normal file
@ -0,0 +1,60 @@
|
||||
--TEST--
|
||||
Bug #65230 setting locale randomly broken
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (substr(PHP_OS, 0, 3) != 'WIN') {
|
||||
die('skip');
|
||||
}
|
||||
?>
|
||||
--INI--
|
||||
date.timezone=Europe/Berlin
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
function test($locale, $value)
|
||||
{
|
||||
$newlocale = setlocale(LC_ALL, $locale);
|
||||
$conv = localeconv();
|
||||
$sep = $conv['decimal_point'];
|
||||
|
||||
printf("%s\n--------------------------\n", $newlocale);
|
||||
printf(" sep: %s\n", $sep);
|
||||
printf(" %%f: %f\n", $value);
|
||||
printf(" %%F: %F\n", $value);
|
||||
printf("date: %s\n", strftime('%x'));
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
test('german', 3.41);
|
||||
test('english', 3.41);
|
||||
test('french', 3.41);
|
||||
test('german', 3.41);
|
||||
--EXPECT--
|
||||
German_Germany.1252
|
||||
--------------------------
|
||||
sep: ,
|
||||
%f: 3,410000
|
||||
%F: 3.410000
|
||||
date: 05.12.2014
|
||||
|
||||
English_United States.1252
|
||||
--------------------------
|
||||
sep: .
|
||||
%f: 3.410000
|
||||
%F: 3.410000
|
||||
date: 12/5/2014
|
||||
|
||||
French_France.1252
|
||||
--------------------------
|
||||
sep: ,
|
||||
%f: 3,410000
|
||||
%F: 3.410000
|
||||
date: 05/12/2014
|
||||
|
||||
German_Germany.1252
|
||||
--------------------------
|
||||
sep: ,
|
||||
%f: 3,410000
|
||||
%F: 3.410000
|
||||
date: 05.12.2014
|
||||
|
@ -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
|
||||
@ -607,7 +611,11 @@ 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
|
||||
|
||||
/*
|
||||
@ -1017,9 +1025,13 @@ 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,
|
||||
@ -1074,9 +1086,13 @@ 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 == '-') {
|
||||
|
@ -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
|
||||
@ -218,7 +222,11 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
|
||||
char char_buf[2]; /* for printing %% and %<unknown> */
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
#ifdef ZTS
|
||||
struct lconv lconv;
|
||||
#else
|
||||
struct lconv *lconv = NULL;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
@ -633,9 +641,13 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
|
||||
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,
|
||||
@ -689,9 +701,13 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
|
||||
* * 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 == '-')
|
||||
|
@ -4,10 +4,6 @@ Bug #12647 (Locale settings affecting float parsing)
|
||||
precision=14
|
||||
--SKIPIF--
|
||||
<?php # try to activate a german locale
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
/* skip on windows until #63688 was fixed */
|
||||
die('skip');
|
||||
}
|
||||
if (setlocale(LC_NUMERIC, "de_DE.UTF-8", "de_DE", "de", "german", "ge", "de_DE.ISO-8859-1") === FALSE) {
|
||||
print "skip Can't find german locale";
|
||||
}
|
||||
|
@ -2,10 +2,6 @@
|
||||
Bug #30638 (localeconv returns wrong LC_NUMERIC settings) (ok to fail on MacOS X)
|
||||
--SKIPIF--
|
||||
<?php # try to activate a german locale
|
||||
if (substr(PHP_OS, 0, 3) == 'WIN') {
|
||||
/* skip on windows until #63688 was fixed */
|
||||
die('skip');
|
||||
}
|
||||
if (setlocale(LC_NUMERIC, "de_DE.UTF-8", "de_DE", "de", "german", "ge", "de_DE.ISO-8859-1") === FALSE) {
|
||||
print "skip setlocale() failed";
|
||||
} elseif (strtolower(php_uname('s')) == 'darwin') {
|
||||
|
Loading…
Reference in New Issue
Block a user