mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
ext/gettext: dcgettext/dcngettext fix for stable branches.
close GH-13594
This commit is contained in:
parent
5e12844d4d
commit
33967aef11
3 changed files with 11 additions and 26 deletions
|
@ -218,10 +218,6 @@ PHP 8.2 UPGRADE NOTES
|
||||||
dba_fetch(string|array $key, $skip, $dba): string|false
|
dba_fetch(string|array $key, $skip, $dba): string|false
|
||||||
is still accepted, but it is recommended to use the new standard variant.
|
is still accepted, but it is recommended to use the new standard variant.
|
||||||
|
|
||||||
- Gettext:
|
|
||||||
. dcgettext/dcngettext throw now an exception if the category's argument if set to
|
|
||||||
`LC_ALL`.
|
|
||||||
|
|
||||||
- MBString
|
- MBString
|
||||||
. mb_check_encoding() now checks input encoding more strictly for
|
. mb_check_encoding() now checks input encoding more strictly for
|
||||||
certain text encodings, including ISO-2022-JP and UTF-7.
|
certain text encodings, including ISO-2022-JP and UTF-7.
|
||||||
|
|
|
@ -62,12 +62,6 @@ ZEND_GET_MODULE(php_gettext)
|
||||||
RETURN_THROWS(); \
|
RETURN_THROWS(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PHP_DCGETTEXT_CATEGORY_CHECK(_arg_num, category) \
|
|
||||||
if (category == LC_ALL) { \
|
|
||||||
zend_argument_value_error(_arg_num, "cannot be LC_ALL"); \
|
|
||||||
RETURN_THROWS(); \
|
|
||||||
}
|
|
||||||
|
|
||||||
PHP_MINFO_FUNCTION(php_gettext)
|
PHP_MINFO_FUNCTION(php_gettext)
|
||||||
{
|
{
|
||||||
php_info_print_table_start();
|
php_info_print_table_start();
|
||||||
|
@ -153,7 +147,9 @@ PHP_FUNCTION(dcgettext)
|
||||||
|
|
||||||
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, ZSTR_LEN(domain))
|
||||||
PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
|
PHP_GETTEXT_LENGTH_CHECK(2, ZSTR_LEN(msgid))
|
||||||
PHP_DCGETTEXT_CATEGORY_CHECK(3, category)
|
if (category == LC_ALL) {
|
||||||
|
RETURN_STR_COPY(msgid);
|
||||||
|
}
|
||||||
|
|
||||||
msgstr = dcgettext(ZSTR_VAL(domain), ZSTR_VAL(msgid), category);
|
msgstr = dcgettext(ZSTR_VAL(domain), ZSTR_VAL(msgid), category);
|
||||||
|
|
||||||
|
@ -268,7 +264,9 @@ PHP_FUNCTION(dcngettext)
|
||||||
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
|
PHP_GETTEXT_DOMAIN_LENGTH_CHECK(1, domain_len)
|
||||||
PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
|
PHP_GETTEXT_LENGTH_CHECK(2, msgid1_len)
|
||||||
PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
|
PHP_GETTEXT_LENGTH_CHECK(3, msgid2_len)
|
||||||
PHP_DCGETTEXT_CATEGORY_CHECK(5, category)
|
if (category == LC_ALL) {
|
||||||
|
RETURN_STRING(msgid1);
|
||||||
|
}
|
||||||
|
|
||||||
msgstr = dcngettext(domain, msgid1, msgid2, count, category);
|
msgstr = dcngettext(domain, msgid1, msgid2, count, category);
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,9 @@ dcgettext with LC_ALL is undefined behavior.
|
||||||
gettext
|
gettext
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
try {
|
var_dump(dcgettext('dngettextTest', 'item', LC_ALL));
|
||||||
dcgettext('dngettextTest', 'item', LC_ALL);
|
var_dump(dcngettext('dngettextTest', 'item', 'item2', 1, LC_ALL));
|
||||||
} catch (ValueError $e) {
|
|
||||||
echo $e->getMessage() . PHP_EOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
dcngettext('dngettextTest', 'item', 'item2', 1, LC_ALL);
|
|
||||||
} catch (ValueError $e) {
|
|
||||||
echo $e->getMessage();
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
--EXPECTF--
|
--EXPECT--
|
||||||
dcgettext(): Argument #3 ($category) cannot be LC_ALL
|
string(4) "item"
|
||||||
dcngettext(): Argument #5 ($category) cannot be LC_ALL
|
string(4) "item"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue