com php-src: Remove string category support in setlocale(): NEWS UPGRADING ext/standard/string.c ext/standard/tests/strings/setlocale_er ror.phpt
| From: | Nikita Popov | Date: | Sat, 17 Jan 2015 17:26:45 +0000 |
| Subject: | com php-src: Remove string category support in setlocale(): NEWS UPGRADING ext/standard/string.c ext/standard/tests/strings/setlocale_er ror.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-84148@lists.php.net to get a copy of this message | ||
Commit: 4c115b6b71e31a289d84f72f8664943497b9ee31
Author: Nikita Popov <nikic@php.net> Wed, 10 Sep 2014 17:46:54 +0200
Parents: 9c5eaac18b65038cc377c7335b32889b892cf1fc
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=4c115b6b71e31a289d84f72f8664943497b9ee31
Log:
Remove string category support in setlocale()
Changed paths:
M NEWS
M UPGRADING
M ext/standard/string.c
M ext/standard/tests/strings/setlocale_error.phpt
Diff:
diff --git a/NEWS b/NEWS
index b47565f..f6818c5 100644
--- a/NEWS
+++ b/NEWS
@@ -108,6 +108,7 @@
. Fix user session handlers (See rfc:session.user.return-value). (Sara)
. Added intdiv() function. (Andrea)
. Improved precision of log() function for base 2 and 10. (Marc Bennewitz)
+ . Remove string category support in setlocale(). (Nikita)
- Streams:
. Fixed bug #68532 (convert.base64-encode omits padding bytes).
diff --git a/UPGRADING b/UPGRADING
index cb976fd..f3f25bd 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -75,6 +75,10 @@ PHP X.Y UPGRADE NOTES
. gmp_setbit() and gmp_clrbit() now return FALSE for negative indices, making
them consistent with other GMP functions.
+- Standard:
+ . Removed string category support in setlocale(). Use the LC_* constants
+ instead.
+
========================================
2. New Features
========================================
diff --git a/ext/standard/string.c b/ext/standard/string.c
index f6096d1...8bb8a9c 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -4450,49 +4450,18 @@ PHP_FUNCTION(strip_tags)
PHP_FUNCTION(setlocale)
{
zval *args = NULL;
- zval *pcategory, *plocale;
+ zval *plocale;
zend_string *loc;
char *retval;
- int num_args, cat, i = 0;
+ zend_long cat;
+ int num_args, i = 0;
HashPosition pos;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z+", &pcategory, &args,
&num_args) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l+", &cat, &args, &num_args) ==
FAILURE) {
return;
}
#ifdef HAVE_SETLOCALE
- if (Z_TYPE_P(pcategory) == IS_LONG) {
- cat = (int)Z_LVAL_P(pcategory);
- } else {
- /* FIXME: The following behaviour should be removed. */
- zend_string *category = zval_get_string(pcategory);
-
- php_error_docref(NULL, E_DEPRECATED, "Passing locale category name as string is deprecated.
Use the LC_* -constants instead");
- if (!strcasecmp("LC_ALL", category->val)) {
- cat = LC_ALL;
- } else if (!strcasecmp("LC_COLLATE", category->val)) {
- cat = LC_COLLATE;
- } else if (!strcasecmp("LC_CTYPE", category->val)) {
- cat = LC_CTYPE;
-#ifdef LC_MESSAGES
- } else if (!strcasecmp("LC_MESSAGES", category->val)) {
- cat = LC_MESSAGES;
-#endif
- } else if (!strcasecmp("LC_MONETARY", category->val)) {
- cat = LC_MONETARY;
- } else if (!strcasecmp("LC_NUMERIC", category->val)) {
- cat = LC_NUMERIC;
- } else if (!strcasecmp("LC_TIME", category->val)) {
- cat = LC_TIME;
- } else {
- php_error_docref(NULL, 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->val);
-
- zend_string_release(category);
- RETURN_FALSE;
- }
- zend_string_release(category);
- }
-
if (Z_TYPE(args[0]) == IS_ARRAY) {
zend_hash_internal_pointer_reset_ex(Z_ARRVAL(args[0]), &pos);
}
diff --git a/ext/standard/tests/strings/setlocale_error.phpt
b/ext/standard/tests/strings/setlocale_error.phpt
index 361d00c..ca46764 100644
--- a/ext/standard/tests/strings/setlocale_error.phpt
+++ b/ext/standard/tests/strings/setlocale_error.phpt
@@ -1,7 +1,7 @@
--TEST--
Test setlocale() function : error condition
--INI--
-error_reporting=14335
+error_reporting=E_ALL
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
@@ -35,11 +35,6 @@ echo "\n-- Testing setlocale() function with invalid multiple locales,
'category
//Invalid array of locales
var_dump( setlocale(LC_ALL,"en_US.invalid", "en_AU.invalid",
"ko_KR.invalid") );
-echo "\n-- Testing setlocale() function with invalid category --\n";
-//invalid $category
-$invalid_category = "TEST";
-var_dump( setlocale($invalid_category,"en_US.utf8") );
-
echo "\nDone";
?>
--EXPECTF--
@@ -59,11 +54,4 @@ bool(false)
-- Testing setlocale() function with invalid multiple locales, 'category' = LC_ALL --
bool(false)
--- Testing setlocale() function with invalid category --
-
-Deprecated: setlocale(): Passing locale category name as string is deprecated. Use the LC_*
-constants instead in %s on line %d
-
-Warning: setlocale(): Invalid locale category name TEST, must be one of LC_ALL, LC_COLLATE,
LC_CTYPE, LC_MONETARY, LC_NUMERIC, or LC_TIME in %s on line %d
-bool(false)
-
Done