mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
@- Changed setlocale() to use LC_* constants. (Jani)
This commit is contained in:
parent
225a08e8dd
commit
c29e24c7e2
1 changed files with 32 additions and 22 deletions
|
@ -2362,7 +2362,7 @@ PHP_FUNCTION(strip_tags)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ proto string setlocale(string category, string locale)
|
||||
/* {{{ proto string setlocale(mixed category, string locale)
|
||||
Set locale information */
|
||||
PHP_FUNCTION(setlocale)
|
||||
{
|
||||
|
@ -2375,10 +2375,17 @@ PHP_FUNCTION(setlocale)
|
|||
if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &pcategory, &plocale)==FAILURE)
|
||||
WRONG_PARAM_COUNT;
|
||||
#ifdef HAVE_SETLOCALE
|
||||
convert_to_string_ex(pcategory);
|
||||
convert_to_string_ex(plocale);
|
||||
category = *pcategory;
|
||||
locale = *plocale;
|
||||
|
||||
if (Z_TYPE_PP(pcategory) == IS_LONG) {
|
||||
convert_to_long_ex(pcategory);
|
||||
cat = Z_LVAL_PP(pcategory);
|
||||
} else { /* FIXME: The following behaviour should be removed. */
|
||||
php_error(E_NOTICE,"Passing locale category name as string is deprecated. Use the LC_* -constants instead.");
|
||||
convert_to_string_ex(pcategory);
|
||||
category = *pcategory;
|
||||
|
||||
if (!strcasecmp ("LC_ALL", category->value.str.val))
|
||||
cat = LC_ALL;
|
||||
else if (!strcasecmp ("LC_COLLATE", category->value.str.val))
|
||||
|
@ -2399,10 +2406,13 @@ PHP_FUNCTION(setlocale)
|
|||
php_error(E_WARNING,"Invalid locale category name %s, must be one of LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC or LC_TIME", category->value.str.val);
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (!strcmp ("0", locale->value.str.val))
|
||||
}
|
||||
if (!strcmp ("0", locale->value.str.val)) {
|
||||
loc = NULL;
|
||||
else
|
||||
} else {
|
||||
loc = locale->value.str.val;
|
||||
}
|
||||
|
||||
retval = setlocale (cat, loc);
|
||||
if (retval) {
|
||||
/* Remember if locale was changed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue