mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
use more suitable types here, too
and simplify the loop
This commit is contained in:
parent
198c2ec5f0
commit
2334d8335b
1 changed files with 35 additions and 39 deletions
|
@ -219,7 +219,7 @@ PHP_NAMED_FUNCTION(zif_locale_get_default)
|
|||
/* {{{ proto static string Locale::setDefault( string $locale )
|
||||
Set default locale */
|
||||
/* }}} */
|
||||
/* {{{ proto static string locale_set_default( string $locale )
|
||||
/* {{{ proto sta tic string locale_set_default( string $locale )
|
||||
Set default locale */
|
||||
PHP_NAMED_FUNCTION(zif_locale_set_default)
|
||||
{
|
||||
|
@ -258,15 +258,15 @@ PHP_NAMED_FUNCTION(zif_locale_set_default)
|
|||
*/
|
||||
static zend_string* get_icu_value_internal( const char* loc_name , char* tag_name, int* result , int fromParseLocale)
|
||||
{
|
||||
zend_string* tag_value = NULL;
|
||||
int32_t tag_value_len = 512;
|
||||
zend_string* tag_value = NULL;
|
||||
int32_t tag_value_len = 512;
|
||||
|
||||
int singletonPos = 0;
|
||||
char* mod_loc_name = NULL;
|
||||
int grOffset = 0;
|
||||
zend_off_t singletonPos = 0;
|
||||
char* mod_loc_name = NULL;
|
||||
zend_off_t grOffset = 0;
|
||||
|
||||
int32_t buflen = 512;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int32_t buflen = 512;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
|
||||
if( strcmp(tag_name, LOC_CANONICALIZE_TAG) != 0 ){
|
||||
|
@ -433,12 +433,12 @@ static void get_icu_value_src_php( char* tag_name, INTERNAL_FUNCTION_PARAMETERS)
|
|||
}
|
||||
|
||||
}
|
||||
/* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto static string Locale::getScript($locale)
|
||||
/* {{{ proto stat ic string Locale::getScript($locale)
|
||||
* gets the script for the $locale
|
||||
}}} */
|
||||
/* {{{ proto static string locale_get_script($locale)
|
||||
/* {{{ proto stati c string locale_get_script($locale)
|
||||
* gets the script for the $locale
|
||||
*/
|
||||
PHP_FUNCTION( locale_get_script )
|
||||
|
@ -449,8 +449,8 @@ PHP_FUNCTION( locale_get_script )
|
|||
|
||||
/* {{{ proto static string Locale::getRegion($locale)
|
||||
* gets the region for the $locale
|
||||
}}} */
|
||||
/* {{{ proto static string locale_get_region($locale)
|
||||
}}} */
|
||||
/* {{{ p roto static string locale_get_region($locale)
|
||||
* gets the region for the $locale
|
||||
*/
|
||||
PHP_FUNCTION( locale_get_region )
|
||||
|
@ -992,40 +992,36 @@ PHP_FUNCTION(locale_compose)
|
|||
*/
|
||||
static zend_string* get_private_subtags(const char* loc_name)
|
||||
{
|
||||
zend_string* result =NULL;
|
||||
int singletonPos = 0;
|
||||
int len =0;
|
||||
const char* mod_loc_name =NULL;
|
||||
zend_string* result = NULL;
|
||||
zend_off_t singletonPos = 0;
|
||||
size_t len = 0;
|
||||
const char* mod_loc_name =NULL;
|
||||
|
||||
if( loc_name && (len = strlen(loc_name)>0 ) ){
|
||||
mod_loc_name = loc_name ;
|
||||
len = strlen(mod_loc_name);
|
||||
while( (singletonPos = getSingletonPos(mod_loc_name))!= -1){
|
||||
|
||||
if( singletonPos!=-1){
|
||||
if( (*(mod_loc_name+singletonPos)=='x') || (*(mod_loc_name+singletonPos)=='X') ){
|
||||
/* private subtag start found */
|
||||
if( singletonPos + 2 == len){
|
||||
/* loc_name ends with '-x-' ; return NULL */
|
||||
}
|
||||
else{
|
||||
/* result = mod_loc_name + singletonPos +2; */
|
||||
result = zend_string_init(mod_loc_name + singletonPos+2 , (len -( singletonPos +2) ), 0);
|
||||
}
|
||||
break;
|
||||
while( (singletonPos = getSingletonPos(mod_loc_name)) > -1){
|
||||
if( (*(mod_loc_name+singletonPos)=='x') || (*(mod_loc_name+singletonPos)=='X') ){
|
||||
/* private subtag start found */
|
||||
if( singletonPos + 2 == len){
|
||||
/* loc_name ends with '-x-' ; return NULL */
|
||||
}
|
||||
else{
|
||||
if( singletonPos + 1 >= len){
|
||||
/* String end */
|
||||
break;
|
||||
} else {
|
||||
/* singleton found but not a private subtag , hence check further in the string for the private subtag */
|
||||
mod_loc_name = mod_loc_name + singletonPos +1;
|
||||
len = strlen(mod_loc_name);
|
||||
}
|
||||
/* result = mod_loc_name + singletonPos +2; */
|
||||
result = zend_string_init(mod_loc_name + singletonPos+2 , (len -( singletonPos +2) ), 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
else{
|
||||
if((size_t)(singletonPos + 1) >= len){
|
||||
/* String end */
|
||||
break;
|
||||
} else {
|
||||
/* singleton found but not a private subtag , hence check further in the string for the private subtag */
|
||||
mod_loc_name = mod_loc_name + singletonPos +1;
|
||||
len = strlen(mod_loc_name);
|
||||
}
|
||||
}
|
||||
|
||||
} /* end of while */
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue