mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Make mb_ereg(i) argument a normal string argument
Instead of manually handling the string conversion, use the standard zpp mechanism.
This commit is contained in:
parent
06ed6b8978
commit
4a4c68d90d
3 changed files with 12 additions and 22 deletions
|
@ -853,16 +853,16 @@ PHP_FUNCTION(mb_regex_encoding)
|
||||||
/* {{{ _php_mb_regex_ereg_exec */
|
/* {{{ _php_mb_regex_ereg_exec */
|
||||||
static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||||
{
|
{
|
||||||
zval *arg_pattern, *array = NULL;
|
zval *array = NULL;
|
||||||
char *string;
|
char *arg_pattern, *string;
|
||||||
size_t string_len;
|
size_t arg_pattern_len, string_len;
|
||||||
php_mb_regex_t *re;
|
php_mb_regex_t *re;
|
||||||
OnigRegion *regs = NULL;
|
OnigRegion *regs = NULL;
|
||||||
int i, match_len, beg, end;
|
int i, match_len, beg, end;
|
||||||
OnigOptionType options;
|
OnigOptionType options;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zs|z", &arg_pattern, &string, &string_len, &array) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss|z", &arg_pattern, &arg_pattern_len, &string, &string_len, &array) == FAILURE) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,23 +886,13 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
|
||||||
options |= ONIG_OPTION_IGNORECASE;
|
options |= ONIG_OPTION_IGNORECASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* compile the regular expression from the supplied regex */
|
if (arg_pattern_len == 0) {
|
||||||
if (Z_TYPE_P(arg_pattern) != IS_STRING) {
|
|
||||||
/* we convert numbers to integers and treat them as a string */
|
|
||||||
if (Z_TYPE_P(arg_pattern) == IS_DOUBLE) {
|
|
||||||
convert_to_long_ex(arg_pattern); /* get rid of decimal places */
|
|
||||||
}
|
|
||||||
convert_to_string_ex(arg_pattern);
|
|
||||||
/* don't bother doing an extended regex with just a number */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Z_STRLEN_P(arg_pattern) == 0) {
|
|
||||||
php_error_docref(NULL, E_WARNING, "empty pattern");
|
php_error_docref(NULL, E_WARNING, "empty pattern");
|
||||||
RETVAL_FALSE;
|
RETVAL_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRLEN_P(arg_pattern), options, MBREX(current_mbctype), MBREX(regex_default_syntax));
|
re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, MBREX(current_mbctype), MBREX(regex_default_syntax));
|
||||||
if (re == NULL) {
|
if (re == NULL) {
|
||||||
RETVAL_FALSE;
|
RETVAL_FALSE;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -43,7 +43,7 @@ array(3) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Notice: Array to string conversion in %s on line %d
|
Warning: mb_ereg() expects parameter 1 to be string, array given in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
array(3) {
|
array(3) {
|
||||||
[0]=>
|
[0]=>
|
||||||
|
@ -52,8 +52,7 @@ array(3) {
|
||||||
[1]=>
|
[1]=>
|
||||||
int(1)
|
int(1)
|
||||||
[2]=>
|
[2]=>
|
||||||
array(0) {
|
string(0) ""
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Warning: mb_ereg() expects parameter 2 to be string, array given in %s on line %d
|
Warning: mb_ereg() expects parameter 2 to be string, array given in %s on line %d
|
||||||
|
|
|
@ -89,7 +89,7 @@ fclose($fp);
|
||||||
|
|
||||||
echo "Done";
|
echo "Done";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing mb_ereg() : usage variations ***
|
*** Testing mb_ereg() : usage variations ***
|
||||||
|
|
||||||
-- Iteration 1 --
|
-- Iteration 1 --
|
||||||
|
@ -172,7 +172,8 @@ array(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Iteration 16 --
|
-- Iteration 16 --
|
||||||
|
|
||||||
|
Warning: mb_ereg() expects parameter 1 to be string, resource given in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
array(0) {
|
NULL
|
||||||
}
|
|
||||||
Done
|
Done
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue