summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2008-06-30 17:14:48 +0000
committerFelipe Pena <felipe@php.net>2008-06-30 17:14:48 +0000
commit235aab6c0f4178d4d7cf4c4537188fed695f300d (patch)
treee756f49a9dc568e99b9d3a95a4e7a8ef25b99758 /ext/pcre/php_pcre.c
parente7fc9029e63edd6e7b8c81bbea5285c2b1d12bfb (diff)
downloadphp-git-235aab6c0f4178d4d7cf4c4537188fed695f300d.tar.gz
- New parameter parsing API (to preg_replace*)
- Fixed related tests
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 6f47827ef7..af67b284d1 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -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(), &regex, &replace, &subject, &limit, &zcount) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|lZ", &regex, &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;