summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 4a27aef48..e4b23af97 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_mbregex.c,v 1.53.2.1 2006/01/01 12:50:08 sniper Exp $ */
+/* $Id: php_mbregex.c,v 1.53.2.1.2.2 2006/10/11 11:53:02 tony2001 Exp $ */
#ifdef HAVE_CONFIG_H
@@ -517,8 +517,7 @@ PHP_FUNCTION(mb_regex_encoding)
/* {{{ _php_mb_regex_ereg_exec */
static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
{
- zval tmp;
- zval *arg_pattern, *array;
+ zval **arg_pattern, *array;
char *string;
int string_len;
php_mb_regex_t *re;
@@ -529,7 +528,7 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
array = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zs|z", &arg_pattern, &string, &string_len, &array) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs|z", &arg_pattern, &string, &string_len, &array) == FAILURE) {
RETURN_FALSE;
}
@@ -539,18 +538,15 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
}
/* compile the regular expression from the supplied regex */
- if (Z_TYPE_P(arg_pattern) != IS_STRING) {
+ if (Z_TYPE_PP(arg_pattern) != IS_STRING) {
/* we convert numbers to integers and treat them as a string */
- tmp = *arg_pattern;
- zval_copy_ctor(&tmp);
- if (Z_TYPE_P(&tmp) == IS_DOUBLE) {
- convert_to_long(&tmp); /* get rid of decimal places */
+ if (Z_TYPE_PP(arg_pattern) == IS_DOUBLE) {
+ convert_to_long_ex(arg_pattern); /* get rid of decimal places */
}
- convert_to_string(&tmp);
- arg_pattern = &tmp;
+ convert_to_string_ex(arg_pattern);
/* don't bother doing an extended regex with just a number */
}
- re = php_mbregex_compile_pattern(Z_STRVAL_P(arg_pattern), Z_STRLEN_P(arg_pattern), options, MBSTRG(current_mbctype), MBSTRG(regex_default_syntax) TSRMLS_CC);
+ re = php_mbregex_compile_pattern(Z_STRVAL_PP(arg_pattern), Z_STRLEN_PP(arg_pattern), options, MBSTRG(current_mbctype), MBSTRG(regex_default_syntax) TSRMLS_CC);
if (re == NULL) {
RETVAL_FALSE;
goto out;
@@ -567,19 +563,18 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
match_len = 1;
str = string;
if (array != NULL) {
- zval ret_array;
match_len = regs->end[0] - regs->beg[0];
- array_init(&ret_array);
+ zval_dtor(array);
+ array_init(array);
for (i = 0; i < regs->num_regs; i++) {
beg = regs->beg[i];
end = regs->end[i];
if (beg >= 0 && beg < end && end <= string_len) {
- add_index_stringl(&ret_array, i, (char *)&str[beg], end - beg, 1);
+ add_index_stringl(array, i, (char *)&str[beg], end - beg, 1);
} else {
- add_index_bool(&ret_array, i, 0);
+ add_index_bool(array, i, 0);
}
}
- REPLACE_ZVAL_VALUE(&array, &ret_array, 0);
}
if (match_len == 0) {
@@ -590,9 +585,6 @@ out:
if (regs != NULL) {
onig_region_free(regs, 1);
}
- if (arg_pattern == &tmp) {
- zval_dtor(&tmp);
- }
}
/* }}} */
@@ -1104,6 +1096,7 @@ PHP_FUNCTION(mb_ereg_search_init)
WRONG_PARAM_COUNT;
break;
}
+ convert_to_string_ex(arg_str);
if (ZEND_NUM_ARGS() > 1) {
/* create regex pattern buffer */
convert_to_string_ex(arg_pattern);