diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-01 15:18:28 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-01 15:19:46 +0100 |
commit | 06ed6b89780a5eada4966f4a0512d58cda2936c9 (patch) | |
tree | 71aefc4007adcaeb5d956cb3e509219fc7e2c4d8 /ext/mbstring/php_mbregex.c | |
parent | ba5d2e6af3cfd4ee2712339ac013a436f461767d (diff) | |
download | php-git-06ed6b89780a5eada4966f4a0512d58cda2936c9.tar.gz |
Make mb_ereg_replace() pattern argument a string
Diffstat (limited to 'ext/mbstring/php_mbregex.c')
-rw-r--r-- | ext/mbstring/php_mbregex.c | 32 |
1 files changed, 5 insertions, 27 deletions
diff --git a/ext/mbstring/php_mbregex.c b/ext/mbstring/php_mbregex.c index 96c783d589..3307cfd9cf 100644 --- a/ext/mbstring/php_mbregex.c +++ b/ext/mbstring/php_mbregex.c @@ -967,8 +967,6 @@ PHP_FUNCTION(mb_eregi) /* {{{ _php_mb_regex_ereg_replace_exec */ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options, int is_callable) { - zval *arg_pattern_zval; - char *arg_pattern; size_t arg_pattern_len; @@ -991,7 +989,6 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp OnigUChar *pos; OnigUChar *string_lim; char *description = NULL; - char pat_buf[6]; const mbfl_encoding *enc; @@ -1010,16 +1007,16 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp size_t option_str_len = 0; if (!is_callable) { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zss|s", - &arg_pattern_zval, + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sss|s", + &arg_pattern, &arg_pattern_len, &replace, &replace_len, &string, &string_len, &option_str, &option_str_len) == FAILURE) { RETURN_FALSE; } } else { - if (zend_parse_parameters(ZEND_NUM_ARGS(), "zfs|s", - &arg_pattern_zval, + if (zend_parse_parameters(ZEND_NUM_ARGS(), "sfs|s", + &arg_pattern, &arg_pattern_len, &arg_replace_fci, &arg_replace_fci_cache, &string, &string_len, &option_str, &option_str_len) == FAILURE) { @@ -1046,26 +1043,7 @@ static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOp php_error_docref(NULL, E_WARNING, "The 'e' option is no longer supported, use mb_ereg_replace_callback instead"); RETURN_FALSE; } - if (Z_TYPE_P(arg_pattern_zval) == IS_STRING) { - arg_pattern = Z_STRVAL_P(arg_pattern_zval); - arg_pattern_len = Z_STRLEN_P(arg_pattern_zval); - } else { - php_error_docref(NULL, E_DEPRECATED, - "Non-string patterns will be interpreted as strings in the future. " - "Use an explicit chr() call to preserve the current behavior"); - - /* FIXME: this code is not multibyte aware! */ - convert_to_long_ex(arg_pattern_zval); - pat_buf[0] = (char)Z_LVAL_P(arg_pattern_zval); - pat_buf[1] = '\0'; - pat_buf[2] = '\0'; - pat_buf[3] = '\0'; - pat_buf[4] = '\0'; - pat_buf[5] = '\0'; - - arg_pattern = pat_buf; - arg_pattern_len = 1; - } + /* create regex pattern buffer */ re = php_mbregex_compile_pattern(arg_pattern, arg_pattern_len, options, MBREX(current_mbctype), syntax); if (re == NULL) { |