Do not fetch default locale once on minit or rinit

The default locale is now requested to ICU when it's needed by using
intl_get_default_locale().
This commit is contained in:
Gustavo Lopes 2012-07-23 16:38:27 +02:00
parent 0dfcc3e798
commit c052b9c99a
8 changed files with 15 additions and 24 deletions

View file

@ -48,7 +48,7 @@ static void collator_ctor(INTERNAL_FUNCTION_PARAMETERS)
co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC ); co = (Collator_object *) zend_object_store_get_object( object TSRMLS_CC );
if(locale_len == 0) { if(locale_len == 0) {
locale = INTL_G(default_locale); locale = intl_locale_get_default(TSRMLS_C);
} }
/* Open ICU collator. */ /* Open ICU collator. */

View file

@ -40,7 +40,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
{ {
zval *object; zval *object;
char *locale_str; const char *locale_str;
int locale_len = 0; int locale_len = 0;
Locale locale; Locale locale;
long date_type = 0; long date_type = 0;
@ -72,7 +72,7 @@ static void datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value); INTL_CHECK_LOCALE_LEN_OBJ(locale_len, return_value);
if (locale_len == 0) { if (locale_len == 0) {
locale_str = INTL_G(default_locale); locale_str = intl_locale_get_default(TSRMLS_C);
} }
locale = Locale::createFromName(locale_str); locale = Locale::createFromName(locale_str);

View file

@ -56,7 +56,7 @@ static void numfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
} }
if(locale_len == 0) { if(locale_len == 0) {
locale = INTL_G(default_locale); locale = intl_locale_get_default(TSRMLS_C);
} }
/* Create an ICU number formatter. */ /* Create an ICU number formatter. */

View file

@ -390,7 +390,7 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
} }
if(loc_name_len == 0) { if(loc_name_len == 0) {
loc_name = INTL_G(default_locale); loc_name = intl_locale_get_default(TSRMLS_C);
} }
/* Call ICU get */ /* Call ICU get */
@ -496,7 +496,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
} }
if(loc_name_len == 0) { if(loc_name_len == 0) {
loc_name = INTL_G(default_locale); loc_name = intl_locale_get_default(TSRMLS_C);
} }
if( strcmp(tag_name, DISP_NAME) != 0 ){ if( strcmp(tag_name, DISP_NAME) != 0 ){
@ -518,7 +518,7 @@ static void get_icu_disp_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAME
/* Check if disp_loc_name passed , if not use default locale */ /* Check if disp_loc_name passed , if not use default locale */
if( !disp_loc_name){ if( !disp_loc_name){
disp_loc_name = estrdup(INTL_G(default_locale)); disp_loc_name = estrdup(intl_locale_get_default(TSRMLS_C));
free_loc_name = 1; free_loc_name = 1;
} }
@ -690,7 +690,7 @@ PHP_FUNCTION( locale_get_keywords )
} }
if(loc_name_len == 0) { if(loc_name_len == 0) {
loc_name = INTL_G(default_locale); loc_name = intl_locale_get_default(TSRMLS_C);
} }
/* Get the keywords */ /* Get the keywords */
@ -1097,7 +1097,7 @@ PHP_FUNCTION(locale_parse)
} }
if(loc_name_len == 0) { if(loc_name_len == 0) {
loc_name = INTL_G(default_locale); loc_name = intl_locale_get_default(TSRMLS_C);
} }
array_init( return_value ); array_init( return_value );
@ -1145,7 +1145,7 @@ PHP_FUNCTION(locale_get_all_variants)
} }
if(loc_name_len == 0) { if(loc_name_len == 0) {
loc_name = INTL_G(default_locale); loc_name = intl_locale_get_default(TSRMLS_C);
} }
@ -1251,7 +1251,7 @@ PHP_FUNCTION(locale_filter_matches)
} }
if(loc_range_len == 0) { if(loc_range_len == 0) {
loc_range = INTL_G(default_locale); loc_range = intl_locale_get_default(TSRMLS_C);
} }
if( strcmp(loc_range,"*")==0){ if( strcmp(loc_range,"*")==0){
@ -1537,7 +1537,7 @@ PHP_FUNCTION(locale_lookup)
} }
if(loc_range_len == 0) { if(loc_range_len == 0) {
loc_range = INTL_G(default_locale); loc_range = intl_locale_get_default(TSRMLS_C);
} }
hash_arr = HASH_OF(arr); hash_arr = HASH_OF(arr);

View file

@ -61,7 +61,7 @@ static void msgfmt_ctor(INTERNAL_FUNCTION_PARAMETERS)
} }
if(locale_len == 0) { if(locale_len == 0) {
locale = INTL_G(default_locale); locale = intl_locale_get_default(TSRMLS_C);
} }
#ifdef MSG_FORMAT_QUOTE_APOS #ifdef MSG_FORMAT_QUOTE_APOS

View file

@ -134,7 +134,7 @@ PHP_FUNCTION( msgfmt_format_message )
} }
if(slocale_len == 0) { if(slocale_len == 0) {
slocale = INTL_G(default_locale); slocale = intl_locale_get_default(TSRMLS_C);
} }
#ifdef MSG_FORMAT_QUOTE_APOS #ifdef MSG_FORMAT_QUOTE_APOS

View file

@ -126,7 +126,7 @@ PHP_FUNCTION( msgfmt_parse_message )
} }
if(slocale_len == 0) { if(slocale_len == 0) {
slocale = INTL_G(default_locale); slocale = intl_locale_get_default(TSRMLS_C);
} }
#ifdef MSG_FORMAT_QUOTE_APOS #ifdef MSG_FORMAT_QUOTE_APOS

View file

@ -1011,11 +1011,6 @@ PHP_MINIT_FUNCTION( intl )
/* Global error handling. */ /* Global error handling. */
intl_error_init( NULL TSRMLS_CC ); intl_error_init( NULL TSRMLS_CC );
/* Set the default_locale value */
if( INTL_G(default_locale) == NULL ) {
INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
}
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */
@ -1039,10 +1034,6 @@ PHP_MSHUTDOWN_FUNCTION( intl )
*/ */
PHP_RINIT_FUNCTION( intl ) PHP_RINIT_FUNCTION( intl )
{ {
/* Set the default_locale value */
if( INTL_G(default_locale) == NULL ) {
INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
}
return SUCCESS; return SUCCESS;
} }
/* }}} */ /* }}} */