]> granicus.if.org Git - php/commitdiff
Remove checks for locale.h, setlocale, localeconv
authorPeter Kokot <peterkokot@gmail.com>
Sun, 24 Feb 2019 09:21:25 +0000 (10:21 +0100)
committerPeter Kokot <peterkokot@gmail.com>
Sun, 7 Apr 2019 16:32:54 +0000 (18:32 +0200)
The `<loccale.h>` header file, setlocale, and localeconv are part of the
standard C89 [1] and on current systems can be used unconditionally.

Since PHP 7.4 requires at least C89 or greater, the `HAVE_LOCALE_H`,
`HAVE_SETLOCALE`, and `HAVE_LOCALECONV` symbols defined by Autoconf in
configure.ac [2] can be ommitted and simplifed.

The bundled libmagic (file) has also been patched already in version
5.35 and up in upstream location so when it will be patched also in
php-src the check for locale.h header is still left in the configure.ac
and in windows headers definition file.

[1] https://port70.net/~nsz/c/c89/c89-draft.html#4.4
[2] https://git.savannah.gnu.org/cgit/autoconf.git/tree/lib/autoconf/headers.m4

Omit the bundled libmagic files

20 files changed:
Zend/zend_operators.h
configure.ac
ext/pcre/php_pcre.c
ext/pcre/php_pcre.h
ext/readline/readline_cli.c
ext/standard/basic_functions.c
ext/standard/formatted_print.c
ext/standard/html.c
ext/standard/php_string.h
ext/standard/scanf.c
ext/standard/string.c
main/main.c
main/snprintf.c
main/spprintf.c
sapi/cgi/cgi_main.c
sapi/cli/php_cli.c
sapi/cli/php_cli_server.c
sapi/fpm/fpm/fpm_main.c
sapi/phpdbg/phpdbg_out.c
win32/build/config.w32.h.in

index c5965256e18b60b5d972151245d6c6f686b418af..6fe0bddc3d8be19e12bf6887040edee4eb0485c0 100644 (file)
@@ -451,7 +451,7 @@ ZEND_API void ZEND_FASTCALL zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_D
                convert_scalar_to_number(pzv);                                  \
        }
 
-#if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER)
+#if defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER)
 /* This performance improvement of tolower() on Windows gives 10-18% on bench.php */
 #define ZEND_USE_TOLOWER_L 1
 #endif
index 6cce23636441aeb835d4ea149fa515597b3fcece..88629a7b49b61cb6f737855cfefe0a7201bc4ea6 100644 (file)
@@ -628,8 +628,6 @@ random \
 rand_r \
 scandir \
 setitimer \
-setlocale \
-localeconv \
 setenv \
 setpgid \
 setsockopt \
index 55864206c8814b1a7e89c67f21e8b094b8c9b924..9ab5d4465666f3f15e3a5a9562feebfe3d93feac 100644 (file)
@@ -94,7 +94,6 @@ static MUTEX_T pcre_mt = NULL;
 #define php_pcre_mutex_unlock()
 #endif
 
-#if HAVE_SETLOCALE
 ZEND_TLS HashTable char_tables;
 
 static void php_pcre_free_char_table(zval *data)
@@ -102,7 +101,6 @@ static void php_pcre_free_char_table(zval *data)
        void *ptr = Z_PTR_P(data);
        pefree(ptr, 1);
 }/*}}}*/
-#endif
 
 static void pcre_handle_exec_error(int pcre_code) /* {{{ */
 {
@@ -271,9 +269,7 @@ static PHP_GINIT_FUNCTION(pcre) /* {{{ */
 #endif
 
        php_pcre_init_pcre2(1);
-#if HAVE_SETLOCALE
        zend_hash_init(&char_tables, 1, NULL, php_pcre_free_char_table, 1);
-#endif
 }
 /* }}} */
 
@@ -284,10 +280,7 @@ static PHP_GSHUTDOWN_FUNCTION(pcre) /* {{{ */
        }
 
        php_pcre_shutdown_pcre2();
-#if HAVE_SETLOCALE
        zend_hash_destroy(&char_tables);
-#endif
-
        php_pcre_mutex_free();
 }
 /* }}} */
@@ -578,24 +571,19 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
        char                            *pattern;
        size_t                           pattern_len;
        uint32_t                         poptions = 0;
-#if HAVE_SETLOCALE
        const uint8_t       *tables = NULL;
-#endif
        zval                *zv;
        pcre_cache_entry         new_entry;
        int                                      rc;
        zend_string             *key;
        pcre_cache_entry *ret;
 
-#if HAVE_SETLOCALE
        if (BG(locale_string) &&
                (ZSTR_LEN(BG(locale_string)) != 1 && ZSTR_VAL(BG(locale_string))[0] != 'C')) {
                key = zend_string_alloc(ZSTR_LEN(regex) + ZSTR_LEN(BG(locale_string)) + 1, 0);
                memcpy(ZSTR_VAL(key), ZSTR_VAL(BG(locale_string)), ZSTR_LEN(BG(locale_string)) + 1);
                memcpy(ZSTR_VAL(key) + ZSTR_LEN(BG(locale_string)), ZSTR_VAL(regex), ZSTR_LEN(regex) + 1);
-       } else
-#endif
-       {
+       } else {
                key = regex;
        }
 
@@ -603,11 +591,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
           back the compiled pattern, otherwise go on and compile it. */
        zv = zend_hash_find(&PCRE_G(pcre_cache), key);
        if (zv) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                return (pcre_cache_entry*)Z_PTR_P(zv);
        }
 
@@ -617,11 +603,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
           get to the end without encountering a delimiter. */
        while (isspace((int)*(unsigned char *)p)) p++;
        if (*p == 0) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                php_error_docref(NULL, E_WARNING,
                                                 p < ZSTR_VAL(regex) + ZSTR_LEN(regex) ? "Null byte in regex" : "Empty regular expression");
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
@@ -632,11 +616,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
           or a backslash. */
        delimiter = *p++;
        if (isalnum((int)*(unsigned char *)&delimiter) || delimiter == '\\') {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                php_error_docref(NULL,E_WARNING, "Delimiter must not be alphanumeric or backslash");
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
                return NULL;
@@ -677,11 +659,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
        }
 
        if (*pp == 0) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                if (pp < ZSTR_VAL(regex) + ZSTR_LEN(regex)) {
                        php_error_docref(NULL,E_WARNING, "Null byte in regex");
                } else if (start_delimiter == end_delimiter) {
@@ -742,11 +722,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
                                }
                                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
                                efree(pattern);
-#if HAVE_SETLOCALE
                                if (key != regex) {
                                        zend_string_release_ex(key, 0);
                                }
-#endif
                                return NULL;
                }
        }
@@ -755,15 +733,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
                php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead");
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
                efree(pattern);
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                return NULL;
        }
 
-#if HAVE_SETLOCALE
        if (key != regex) {
                tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string));
                if (!tables) {
@@ -782,7 +757,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
                }
                pcre2_set_character_tables(cctx, tables);
        }
-#endif
 
        /* Set extra options for the compile context. */
        if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) {
@@ -798,11 +772,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
        }
 
        if (re == NULL) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                pcre2_get_error_message(errnumber, error, sizeof(error));
                php_error_docref(NULL,E_WARNING, "Compilation failed: %s at offset %zu", error, erroffset);
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
@@ -847,11 +819,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 
        rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);
        if (rc < 0) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                php_error_docref(NULL, E_WARNING, "Internal pcre2_pattern_info() error %d", rc);
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
                return NULL;
@@ -859,11 +829,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
 
        rc = pcre2_pattern_info(re, PCRE2_INFO_NAMECOUNT, &new_entry.name_count);
        if (rc < 0) {
-#if HAVE_SETLOCALE
                if (key != regex) {
                        zend_string_release_ex(key, 0);
                }
-#endif
                php_error_docref(NULL, E_WARNING, "Internal pcre_pattern_info() error %d", rc);
                pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
                return NULL;
@@ -887,11 +855,9 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache(zend_string *regex)
                ret = zend_hash_add_new_mem(&PCRE_G(pcre_cache), key, &new_entry, sizeof(pcre_cache_entry));
        }
 
-#if HAVE_SETLOCALE
        if (key != regex) {
                zend_string_release_ex(key, 0);
        }
-#endif
 
        return ret;
 }
index b59f16e89803b8ec0a46a1339cc7ad335a2a04da..1a28d1733a7d483eb3b242c19659e48d57a629c1 100644 (file)
@@ -25,9 +25,7 @@
 #include "pcre2.h"
 #endif
 
-#if HAVE_LOCALE_H
 #include <locale.h>
-#endif
 
 PHPAPI zend_string *php_pcre_replace(zend_string *regex, zend_string *subject_str, char *subject, size_t subject_len, zend_string *replace_str, size_t limit, size_t *replace_count);
 PHPAPI pcre2_code* pcre_get_compiled_regex(zend_string *regex, uint32_t *capture_count);
index f55de8e4f962774ad27cb0f582f2dee582404d82..1629ed012eafae25ef2416cc92ed4170042784c2 100644 (file)
 #include "zend_modules.h"
 
 #include "SAPI.h"
-
-#if HAVE_SETLOCALE
 #include <locale.h>
-#endif
 #include "zend.h"
 #include "zend_extensions.h"
 #include "php_ini.h"
index ba4b5ee68cc458f2d383be47d68f3671e326088f..29ee2fb3f255445ba4236c6c27583461dbd6b91b 100644 (file)
@@ -76,10 +76,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
 #endif
 
 #include <string.h>
-
-#if HAVE_LOCALE_H
-# include <locale.h>
-#endif
+#include <locale.h>
 
 #if HAVE_SYS_MMAN_H
 # include <sys/mman.h>
@@ -3685,7 +3682,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
        BASIC_MINIT_SUBMODULE(password)
        BASIC_MINIT_SUBMODULE(mt_rand)
 
-#if defined(HAVE_LOCALECONV) && defined(ZTS)
+#if defined(ZTS)
        BASIC_MINIT_SUBMODULE(localeconv)
 #endif
 
@@ -3769,7 +3766,7 @@ PHP_MSHUTDOWN_FUNCTION(basic) /* {{{ */
        BASIC_MSHUTDOWN_SUBMODULE(url_scanner_ex)
        BASIC_MSHUTDOWN_SUBMODULE(file)
        BASIC_MSHUTDOWN_SUBMODULE(standard_filters)
-#if defined(HAVE_LOCALECONV) && defined(ZTS)
+#if defined(ZTS)
        BASIC_MSHUTDOWN_SUBMODULE(localeconv)
 #endif
        BASIC_MSHUTDOWN_SUBMODULE(crypt)
index e534d9475364abd3d01b67ec9e85317f06e437a1..b804cda5002fcee6e2fafb99b122c10fcf366b88 100644 (file)
@@ -23,7 +23,6 @@
 #include "zend_execute.h"
 #include <stdio.h>
 
-#ifdef HAVE_LOCALE_H
 #include <locale.h>
 #ifdef ZTS
 #include "ext/standard/php_string.h"
@@ -31,9 +30,6 @@
 #else
 #define LCONV_DECIMAL_POINT (*lconv->decimal_point)
 #endif
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
 
 #define ALIGN_LEFT 0
 #define ALIGN_RIGHT 1
@@ -232,12 +228,10 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
        char *s = NULL;
        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",
@@ -268,12 +262,10 @@ php_sprintf_appenddouble(zend_string **buffer, size_t *pos,
                case 'E':
                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:'.',
@@ -296,12 +288,10 @@ 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;
index d69082939c6b05896d1c853bd9f024af2186bd86..0cdfca6d8553f4ffd4576a10ee01a55dc3446f71 100644 (file)
@@ -45,9 +45,7 @@
 #include "php_standard.h"
 #include "php_string.h"
 #include "SAPI.h"
-#if HAVE_LOCALE_H
 #include <locale.h>
-#endif
 #if HAVE_LANGINFO_H
 #include <langinfo.h>
 #endif
@@ -408,14 +406,13 @@ static enum entity_charset determine_charset(char *charset_hint)
        }
 
        /* try to detect the charset for the locale */
-#if HAVE_NL_LANGINFO && HAVE_LOCALE_H && defined(CODESET)
+#if HAVE_NL_LANGINFO && defined(CODESET)
        charset_hint = nl_langinfo(CODESET);
        if (charset_hint != NULL && (len=strlen(charset_hint)) != 0) {
                goto det_charset;
        }
 #endif
 
-#if HAVE_LOCALE_H
        /* try to figure out the charset from the locale */
        {
                char *localename;
@@ -441,7 +438,6 @@ static enum entity_charset determine_charset(char *charset_hint)
                        len = strlen(charset_hint);
                }
        }
-#endif
 
 det_charset:
 
index f88861cd5b4d9adb8e3f101837c8940eab26e254..03d1ee8f8ceb39d271a4c183928053658146a9b7 100644 (file)
@@ -98,7 +98,7 @@ PHP_FUNCTION(strcoll);
 PHP_FUNCTION(money_format);
 #endif
 
-#if defined(HAVE_LOCALECONV) && defined(ZTS)
+#if defined(ZTS)
 PHP_MINIT_FUNCTION(localeconv);
 PHP_MSHUTDOWN_FUNCTION(localeconv);
 #endif
@@ -114,11 +114,7 @@ PHP_MINIT_FUNCTION(string_intrin);
 #define strnatcasecmp(a, b) \
        strnatcmp_ex(a, strlen(a), b, strlen(b), 1)
 PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t b_len, int fold_case);
-
-#ifdef HAVE_LOCALECONV
 PHPAPI struct lconv *localeconv_r(struct lconv *out);
-#endif
-
 PHPAPI char *php_strtoupper(char *s, size_t len);
 PHPAPI char *php_strtolower(char *s, size_t len);
 PHPAPI zend_string *php_string_toupper(zend_string *s);
index b128f0d54fa537c7e3a4d893265902f478e720fc..5740cd64124742f26f3c190a5d0667c7ea69c122 100644 (file)
@@ -68,9 +68,7 @@
 #include <ctype.h>
 #include "php.h"
 #include "php_variables.h"
-#ifdef HAVE_LOCALE_H
 #include <locale.h>
-#endif
 #include "zend_execute.h"
 #include "zend_operators.h"
 #include "zend_strtod.h"
index 8fb0e81ab0b2fe3868145167d969bd654b2ff34c..97725bf3f4eb88d5d34a3dad46681d32e1d659df 100644 (file)
@@ -23,9 +23,7 @@
 #include "php_rand.h"
 #include "php_string.h"
 #include "php_variables.h"
-#ifdef HAVE_LOCALE_H
-# include <locale.h>
-#endif
+#include <locale.h>
 #ifdef HAVE_LANGINFO_H
 # include <langinfo.h>
 #endif
@@ -88,12 +86,8 @@ void register_string_constants(INIT_FUNC_ARGS)
        REGISTER_LONG_CONSTANT("PATHINFO_EXTENSION", PHP_PATHINFO_EXTENSION, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("PATHINFO_FILENAME", PHP_PATHINFO_FILENAME, CONST_CS | CONST_PERSISTENT);
 
-#ifdef HAVE_LOCALECONV
        /* If last members of struct lconv equal CHAR_MAX, no grouping is done */
        REGISTER_LONG_CONSTANT("CHAR_MAX", CHAR_MAX, CONST_CS | CONST_PERSISTENT);
-#endif
-
-#ifdef HAVE_LOCALE_H
        REGISTER_LONG_CONSTANT("LC_CTYPE", LC_CTYPE, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LC_NUMERIC", LC_NUMERIC, CONST_CS | CONST_PERSISTENT);
        REGISTER_LONG_CONSTANT("LC_TIME", LC_TIME, CONST_CS | CONST_PERSISTENT);
@@ -103,7 +97,6 @@ void register_string_constants(INIT_FUNC_ARGS)
 # ifdef LC_MESSAGES
        REGISTER_LONG_CONSTANT("LC_MESSAGES", LC_MESSAGES, CONST_CS | CONST_PERSISTENT);
 # endif
-#endif
 
 }
 /* }}} */
@@ -176,15 +169,14 @@ static zend_string *php_hex2bin(const unsigned char *old, const size_t oldlen)
 }
 /* }}} */
 
-#ifdef HAVE_LOCALECONV
 /* {{{ localeconv_r
  * glibc's localeconv is not reentrant, so lets make it so ... sorta */
 PHPAPI struct lconv *localeconv_r(struct lconv *out)
 {
 
-# ifdef ZTS
+#ifdef ZTS
        tsrm_mutex_lock( locale_mutex );
-# endif
+#endif
 
 /*  cur->locinfo is struct __crt_locale_info which implementation is
        hidden in vc14. TODO revisit this and check if a workaround available
@@ -202,15 +194,15 @@ PHPAPI struct lconv *localeconv_r(struct lconv *out)
        *out = *localeconv();
 #endif
 
-# ifdef ZTS
+#ifdef ZTS
        tsrm_mutex_unlock( locale_mutex );
-# endif
+#endif
 
        return out;
 }
 /* }}} */
 
-# ifdef ZTS
+#ifdef ZTS
 /* {{{ PHP_MINIT_FUNCTION
  */
 PHP_MINIT_FUNCTION(localeconv)
@@ -229,7 +221,6 @@ PHP_MSHUTDOWN_FUNCTION(localeconv)
        return SUCCESS;
 }
 /* }}} */
-# endif
 #endif
 
 /* {{{ proto string bin2hex(string data)
@@ -4838,7 +4829,6 @@ PHP_FUNCTION(setlocale)
                Z_PARAM_VARIADIC('+', args, num_args)
        ZEND_PARSE_PARAMETERS_END();
 
-#ifdef HAVE_SETLOCALE
        idx = 0;
        while (1) {
                if (Z_TYPE(args[0]) == IS_ARRAY) {
@@ -4907,7 +4897,6 @@ PHP_FUNCTION(setlocale)
                }
        }
 
-#endif
        RETURN_FALSE;
 }
 /* }}} */
@@ -5600,7 +5589,6 @@ PHP_FUNCTION(localeconv)
        array_init(&grouping);
        array_init(&mon_grouping);
 
-#ifdef HAVE_LOCALECONV
        {
                struct lconv currlocdata;
 
@@ -5637,30 +5625,6 @@ PHP_FUNCTION(localeconv)
                add_assoc_long(  return_value, "p_sign_posn",       currlocdata.p_sign_posn);
                add_assoc_long(  return_value, "n_sign_posn",       currlocdata.n_sign_posn);
        }
-#else
-       /* Ok, it doesn't look like we have locale info floating around, so I guess it
-          wouldn't hurt to just go ahead and return the POSIX locale information?  */
-
-       add_index_long(&grouping, 0, -1);
-       add_index_long(&mon_grouping, 0, -1);
-
-       add_assoc_string(return_value, "decimal_point",     "\x2E");
-       add_assoc_string(return_value, "thousands_sep",     "");
-       add_assoc_string(return_value, "int_curr_symbol",   "");
-       add_assoc_string(return_value, "currency_symbol",   "");
-       add_assoc_string(return_value, "mon_decimal_point", "\x2E");
-       add_assoc_string(return_value, "mon_thousands_sep", "");
-       add_assoc_string(return_value, "positive_sign",     "");
-       add_assoc_string(return_value, "negative_sign",     "");
-       add_assoc_long(  return_value, "int_frac_digits",   CHAR_MAX);
-       add_assoc_long(  return_value, "frac_digits",       CHAR_MAX);
-       add_assoc_long(  return_value, "p_cs_precedes",     CHAR_MAX);
-       add_assoc_long(  return_value, "p_sep_by_space",    CHAR_MAX);
-       add_assoc_long(  return_value, "n_cs_precedes",     CHAR_MAX);
-       add_assoc_long(  return_value, "n_sep_by_space",    CHAR_MAX);
-       add_assoc_long(  return_value, "p_sign_posn",       CHAR_MAX);
-       add_assoc_long(  return_value, "n_sign_posn",       CHAR_MAX);
-#endif
 
        zend_hash_str_update(Z_ARRVAL_P(return_value), "grouping", sizeof("grouping")-1, &grouping);
        zend_hash_str_update(Z_ARRVAL_P(return_value), "mon_grouping", sizeof("mon_grouping")-1, &mon_grouping);
index 95f6157d454c05d3f94302ee6c567b5d33827f09..5eb34b7fa4e95f0124d85d9974419c9d5fabf524 100644 (file)
 #endif
 
 #include <signal.h>
-
-#if HAVE_SETLOCALE
 #include <locale.h>
-#endif
 #include "zend.h"
 #include "zend_types.h"
 #include "zend_extensions.h"
@@ -2176,11 +2173,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
        zuf.getenv_function = sapi_getenv;
        zuf.resolve_path_function = php_resolve_path_for_zend;
        zend_startup(&zuf);
-
-#if HAVE_SETLOCALE
        setlocale(LC_CTYPE, "");
        zend_update_current_locale();
-#endif
 
 #if HAVE_TZSET
        tzset();
index 15ed08175e740494c796923c51b3cec9c1cfbe5f..e3e0993ab5a910eaa3635ce7fb7ba6ca2fa81a90 100644 (file)
@@ -34,7 +34,6 @@
 #include <inttypes.h>
 #endif
 
-#ifdef HAVE_LOCALE_H
 #include <locale.h>
 #ifdef ZTS
 #include "ext/standard/php_string.h"
@@ -42,9 +41,6 @@
 #else
 #define LCONV_DECIMAL_POINT (*lconv->decimal_point)
 #endif
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
 
 /*
  * Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -612,12 +608,10 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
        char num_buf[NUM_BUF_SIZE];
        char char_buf[2];                       /* for printing %% and %<unknown> */
 
-#ifdef HAVE_LOCALE_H
 #ifdef ZTS
        struct lconv lconv;
 #else
        struct lconv *lconv = NULL;
-#endif
 #endif
 
        /*
@@ -1025,14 +1019,12 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
                                                s = "INF";
                                                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,
@@ -1086,14 +1078,12 @@ 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 == '-') {
index 193da18c0afa8c2cdc6666c5767bdf6f56dfd93f..a20705016a12f2567708fb2633be475eb8fa6625 100644 (file)
@@ -89,7 +89,6 @@
 #include <inttypes.h>
 #endif
 
-#ifdef HAVE_LOCALE_H
 #include <locale.h>
 #ifdef ZTS
 #include "ext/standard/php_string.h"
@@ -97,9 +96,6 @@
 #else
 #define LCONV_DECIMAL_POINT (*lconv->decimal_point)
 #endif
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
 
 #include "snprintf.h"
 
@@ -215,12 +211,10 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
        char num_buf[NUM_BUF_SIZE];
        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,14 +627,12 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
                                                s = "inf";
                                                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,
@@ -693,14 +685,12 @@ 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 == '-')
index 8a461d8c4471d6108a1463b3e80979e2ff0d45d2..14dccbde1e7763d5d390194d326956c43c3246ba 100644 (file)
@@ -47,9 +47,7 @@
 
 #include <signal.h>
 
-#if HAVE_SETLOCALE
-# include <locale.h>
-#endif
+#include <locale.h>
 
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
index 364fd1310682043e0ebbe9bcd9d81f616d39b1f0..82051758f3beb1091418313fb69c3db1fb9f4990 100644 (file)
 #endif
 
 #include <signal.h>
-
-#if HAVE_SETLOCALE
 #include <locale.h>
-#endif
 #include "zend.h"
 #include "zend_extensions.h"
 #include "php_ini.h"
index c814b73f269dcc78288df3fad4b1a54e4684b02a..46ba86e9c2bda326d388349f65d84eba636cfee1 100644 (file)
 #if HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+
 #include <signal.h>
-#if HAVE_SETLOCALE
 #include <locale.h>
-#endif
+
 #if HAVE_DLFCN_H
 #include <dlfcn.h>
 #endif
index 3c637d5990114c11d2e98dab2951f76b775f05b9..dd6671e102bed98e94b845c7b53e48c2c94df3ce 100644 (file)
@@ -45,9 +45,7 @@
 
 #include <signal.h>
 
-#if HAVE_SETLOCALE
-# include <locale.h>
-#endif
+#include <locale.h>
 
 #if HAVE_SYS_TYPES_H
 # include <sys/types.h>
index 95316e77c7ad8ae5b8ee3a2b94068ccf46cae411..95f27b3c6fd84af55d8ecb3c6e446b0593f3bc37 100644 (file)
@@ -114,13 +114,8 @@ typedef struct buf_area buffy;
  */
 #define PREFIX( str, length, ch )       *--str = ch ; length++ ; has_prefix = YES
 
-
-#ifdef HAVE_LOCALE_H
 #include <locale.h>
 #define LCONV_DECIMAL_POINT (*lconv->decimal_point)
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
 #define NUL '\0'
 #define S_NULL "(null)"
 #define S_NULL_LEN 6
@@ -155,9 +150,7 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
        char num_buf[NUM_BUF_SIZE];
        char char_buf[2];                       /* for printing %% and %<unknown> */
 
-#ifdef HAVE_LOCALE_H
        struct lconv *lconv = NULL;
-#endif
 
        /*
         * Flag variables
@@ -621,11 +614,10 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
                                                s = "INF";
                                                s_len = 3;
                                        } else {
-#ifdef HAVE_LOCALE_H
                                                if (!lconv) {
                                                        lconv = localeconv();
                                                }
-#endif
+
                                                s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
                                                 (adjust_precision == NO) ? FLOAT_DIGITS : precision,
                                                 (*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
@@ -678,11 +670,10 @@ static int format_converter(register buffy *odp, const char *fmt, zend_bool esca
                                        /*
                                         * * We use &num_buf[ 1 ], so that we have room for the sign
                                         */
-#ifdef HAVE_LOCALE_H
                                        if (!lconv) {
                                                lconv = localeconv();
                                        }
-#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++;
index 938af691a244792362591a5c5a3b5efa8ee15d40..06632b0e20d611a7e9ae8ed77bed4e3d9054bfc9 100644 (file)
@@ -76,8 +76,6 @@
 #define HAVE_MEMMOVE 1
 #define HAVE_PUTENV 1
 #define HAVE_REGCOMP 1
-#define HAVE_SETLOCALE 1
-#define HAVE_LOCALECONV 1
 #define HAVE_LOCALE_H 1
 #ifndef HAVE_LIBBIND
 # define HAVE_SETVBUF 1