From: Nikita Popov Date: Thu, 7 May 2020 16:45:03 +0000 (+0200) Subject: Rename locale_string to ctype_string X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3f769473038509212bbed7cb49d6b7e21009311f;p=php Rename locale_string to ctype_string To make it more obvious that this only refers to the LC_CTYPE locale. --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index a5e806b30c..611a18bd48 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -595,10 +595,10 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in zend_string *key; pcre_cache_entry *ret; - if (locale_aware && BG(locale_string) && - (ZSTR_LEN(BG(locale_string)) != 1 && ZSTR_VAL(BG(locale_string))[0] != 'C')) { + if (locale_aware && BG(ctype_string) && + (ZSTR_LEN(BG(ctype_string)) != 1 && ZSTR_VAL(BG(ctype_string))[0] != 'C')) { key = zend_string_concat2( - ZSTR_VAL(BG(locale_string)), ZSTR_LEN(BG(locale_string)), + ZSTR_VAL(BG(ctype_string)), ZSTR_LEN(BG(ctype_string)), ZSTR_VAL(regex), ZSTR_LEN(regex)); } else { key = regex; @@ -757,7 +757,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in } if (key != regex) { - tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(locale_string)); + tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(ctype_string)); if (!tables) { zend_string *_k; tables = pcre2_maketables(gctx); @@ -768,7 +768,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in efree(pattern); return NULL; } - _k = zend_string_init(ZSTR_VAL(BG(locale_string)), ZSTR_LEN(BG(locale_string)), 1); + _k = zend_string_init(ZSTR_VAL(BG(ctype_string)), ZSTR_LEN(BG(ctype_string)), 1); GC_MAKE_PERSISTENT_LOCAL(_k); zend_hash_add_ptr(&char_tables, _k, (void *)tables); zend_string_release(_k); diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index 5fa7be86db..7e0f4e3da7 100755 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -460,7 +460,7 @@ PHP_RINIT_FUNCTION(basic) /* {{{ */ BG(strtok_string) = NULL; ZVAL_UNDEF(&BG(strtok_zval)); BG(strtok_last) = NULL; - BG(locale_string) = NULL; + BG(ctype_string) = NULL; BG(locale_changed) = 0; BG(array_walk_fci) = empty_fcall_info; BG(array_walk_fci_cache) = empty_fcall_info_cache; @@ -517,9 +517,9 @@ PHP_RSHUTDOWN_FUNCTION(basic) /* {{{ */ if (BG(locale_changed)) { setlocale(LC_ALL, "C"); zend_update_current_locale(); - if (BG(locale_string)) { - zend_string_release_ex(BG(locale_string), 0); - BG(locale_string) = NULL; + if (BG(ctype_string)) { + zend_string_release_ex(BG(ctype_string), 0); + BG(ctype_string) = NULL; } } diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h index 2805addcea..147bc1dd3a 100644 --- a/ext/standard/basic_functions.h +++ b/ext/standard/basic_functions.h @@ -62,7 +62,7 @@ typedef struct _php_basic_globals { HashTable putenv_ht; zval strtok_zval; char *strtok_string; - zend_string *locale_string; /* current LC_CTYPE locale (or NULL for 'C') */ + zend_string *ctype_string; /* current LC_CTYPE locale (or NULL for 'C') */ zend_bool locale_changed; /* locale was changed and has to be restored */ char *strtok_last; char strtok_table[256]; diff --git a/ext/standard/string.c b/ext/standard/string.c index b4a6b7c17e..93ad006244 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -4798,16 +4798,16 @@ PHP_FUNCTION(setlocale) BG(locale_changed) = 1; if (cat == LC_CTYPE || cat == LC_ALL) { - if (BG(locale_string)) { - zend_string_release_ex(BG(locale_string), 0); + if (BG(ctype_string)) { + zend_string_release_ex(BG(ctype_string), 0); } if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { - BG(locale_string) = zend_string_copy(loc); - RETURN_STR(BG(locale_string)); + BG(ctype_string) = zend_string_copy(loc); + RETURN_STR(BG(ctype_string)); } else { - BG(locale_string) = zend_string_init(retval, len, 0); + BG(ctype_string) = zend_string_init(retval, len, 0); zend_string_release_ex(loc, 0); - RETURN_STR_COPY(BG(locale_string)); + RETURN_STR_COPY(BG(ctype_string)); } } else if (len == ZSTR_LEN(loc) && !memcmp(ZSTR_VAL(loc), retval, len)) { RETURN_STR(loc);