summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_mbregex.c
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2019-02-01 15:40:09 +0100
committerNikita Popov <nikita.ppv@gmail.com>2019-02-01 15:40:09 +0100
commit4a4c68d90d8fac4c54932d356a156d000c9c684c (patch)
treed31b48017b98ed55c41921a79d9b68b7d39b8058 /ext/mbstring/php_mbregex.c
parent06ed6b89780a5eada4966f4a0512d58cda2936c9 (diff)
downloadphp-git-4a4c68d90d8fac4c54932d356a156d000c9c684c.tar.gz
Make mb_ereg(i) argument a normal string argument
Instead of manually handling the string conversion, use the standard zpp mechanism.
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r--ext/mbstring/php_mbregex.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c
index 3307cfd9cf..73d3ee3618 100644
--- a/ext/mbstring/php_mbregex.c
+++ b/ext/mbstring/php_mbregex.c
@@ -853,16 +853,16 @@ PHP_FUNCTION(mb_regex_encoding)
/* {{{ _php_mb_regex_ereg_exec */
static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
{
- zval *arg_pattern, *array = NULL;
- char *string;
- size_t string_len;
+ zval *array = NULL;
+ char *arg_pattern, *string;
+ size_t arg_pattern_len, string_len;
php_mb_regex_t *re;
OnigRegion *regs = NULL;
int i, match_len, beg, end;
OnigOptionType options;
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;
}
@@ -886,23 +886,13 @@ static void _php_mb_regex_ereg_exec(INTERNAL_FUNCTION_PARAMETERS, int icase)
options |= ONIG_OPTION_IGNORECASE;
}
- /* compile the regular expression from the supplied regex */
- 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) {
+ if (arg_pattern_len == 0) {
php_error_docref(NULL, E_WARNING, "empty pattern");
RETVAL_FALSE;
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) {
RETVAL_FALSE;
goto out;