mirror of
https://github.com/php/php-src.git
synced 2025-01-22 03:34:19 +08:00
- New parameter parsing API (to preg_replace*)
- Fixed related tests
This commit is contained in:
parent
e7fc9029e6
commit
235aab6c0f
@ -1289,12 +1289,12 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callabl
|
||||
zval **regex,
|
||||
**replace,
|
||||
**subject,
|
||||
**limit,
|
||||
**subject_entry,
|
||||
**zcount;
|
||||
char *result;
|
||||
int result_len;
|
||||
int limit_val = -1;
|
||||
long limit;
|
||||
char *string_key;
|
||||
ulong num_key;
|
||||
char *callback_name;
|
||||
@ -1302,10 +1302,10 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callabl
|
||||
int *replace_count_ptr=NULL;
|
||||
|
||||
/* Get function parameters and do error-checking. */
|
||||
if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 5 ||
|
||||
zend_get_parameters_ex(ZEND_NUM_ARGS(), ®ex, &replace, &subject, &limit, &zcount) == FAILURE) {
|
||||
WRONG_PARAM_COUNT;
|
||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|lZ", ®ex, &replace, &subject, &limit, &zcount) == FAILURE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_callable_replace && Z_TYPE_PP(replace) == IS_ARRAY && Z_TYPE_PP(regex) != IS_ARRAY) {
|
||||
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Parameter mismatch, pattern is a string while replacement is an array");
|
||||
RETURN_FALSE;
|
||||
@ -1330,8 +1330,7 @@ static void preg_replace_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_callabl
|
||||
SEPARATE_ZVAL(subject);
|
||||
|
||||
if (ZEND_NUM_ARGS() > 3) {
|
||||
convert_to_long_ex(limit);
|
||||
limit_val = Z_LVAL_PP(limit);
|
||||
limit_val = limit;
|
||||
}
|
||||
if (ZEND_NUM_ARGS() > 4) {
|
||||
replace_count_ptr =& replace_count;
|
||||
|
@ -18,13 +18,13 @@ var_dump(preg_replace_callback($a,$a,$a,$a,$a));
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %s on line %d
|
||||
Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %s on line %d
|
||||
Warning: preg_replace_callback() expects at least 3 parameters, 1 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %s on line %d
|
||||
Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
|
||||
@ -36,10 +36,9 @@ int(3)
|
||||
Warning: preg_replace_callback(): Requires argument 2, '2', to be a valid callback in %s on line %d
|
||||
int(3)
|
||||
|
||||
Warning: preg_replace_callback(): Requires argument 2, '', to be a valid callback in %s on line 1%d
|
||||
string(0) ""
|
||||
Warning: preg_replace_callback() expects parameter 4 to be long, string given in %s on line %d
|
||||
NULL
|
||||
|
||||
Warning: preg_replace_callback(): Requires argument 2, 'Array', to be a valid callback in %s on line %d
|
||||
array(0) {
|
||||
}
|
||||
Warning: preg_replace_callback() expects parameter 4 to be long, array given in %s on line %d
|
||||
NULL
|
||||
Done
|
||||
|
@ -33,16 +33,16 @@ echo "Done";
|
||||
|
||||
-- Testing preg_replace_callback() function with Zero arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d
|
||||
Warning: preg_replace_callback() expects at least 3 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing preg_replace_callback() function with more than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d
|
||||
Warning: preg_replace_callback() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing preg_replace_callback() function with less than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace_callback() in %spreg_replace_callback_error.php on line %d
|
||||
Warning: preg_replace_callback() expects at least 3 parameters, 2 given in %s on line %d
|
||||
NULL
|
||||
Done
|
||||
|
@ -30,16 +30,16 @@ echo "Done"
|
||||
|
||||
-- Testing preg_replace() function with zero arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d
|
||||
Warning: preg_replace() expects at least 3 parameters, 0 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing preg_replace() function with more than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d
|
||||
Warning: preg_replace() expects at most 5 parameters, 6 given in %s on line %d
|
||||
NULL
|
||||
|
||||
-- Testing preg_replace() function with less than expected no. of arguments --
|
||||
|
||||
Warning: Wrong parameter count for preg_replace() in %spreg_replace_error.php on line %d
|
||||
Warning: preg_replace() expects at least 3 parameters, 2 given in %s on line %d
|
||||
NULL
|
||||
Done
|
||||
|
Loading…
Reference in New Issue
Block a user