[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/ mbstring.c php_mbregex.c php_mbregex.h
hirokawa Sun, 25 Sep 2011 08:22:58 + Revision: http://svn.php.net/viewvc?view=revision&revision=317264 Log: revert the previous patch. Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c U php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c U php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.h Modified: php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c2011-09-25 08:15:50 UTC (rev 317263) +++ php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c2011-09-25 08:22:58 UTC (rev 317264) @@ -467,13 +467,6 @@ ZEND_ARG_INFO(0, string) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_ereg_replace_callback, 0, 0, 3) - ZEND_ARG_INFO(0, pattern) - ZEND_ARG_INFO(0, callback) - ZEND_ARG_INFO(0, string) - ZEND_ARG_INFO(0, option) -ZEND_END_ARG_INFO() - ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_split, 0, 0, 2) ZEND_ARG_INFO(0, pattern) ZEND_ARG_INFO(0, string) Modified: php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c 2011-09-25 08:15:50 UTC (rev 317263) +++ php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c 2011-09-25 08:22:58 UTC (rev 317264) @@ -784,7 +784,7 @@ /* }}} */ /* {{{ _php_mb_regex_ereg_replace_exec */ -static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options, int is_callable) +static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options) { zval **arg_pattern_zval; @@ -793,11 +793,9 @@ char *replace; int replace_len; - zval **arg_replace_zval; char *string; int string_len; - zval **arg_string_zval; char *p; php_mb_regex_t *re; @@ -828,20 +826,14 @@ char *option_str = NULL; int option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|s", - &arg_pattern_zval, - &arg_replace_zval, - &arg_string_zval, - &option_str, &option_str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zss|s", + &arg_pattern_zval, + &replace, &replace_len, + &string, &string_len, + &option_str, &option_str_len) == FAILURE) { RETURN_FALSE; } - replace = Z_STRVAL_PP(arg_replace_zval); - replace_len = Z_STRLEN_PP(arg_replace_zval); - - string = Z_STRVAL_PP(arg_string_zval); - string_len = Z_STRLEN_PP(arg_string_zval); - if (option_str != NULL) { _php_mb_regex_init_options(option_str, option_str_len, &options, &syntax, &eval); } else { @@ -867,7 +859,7 @@ RETURN_FALSE; } - if (eval || is_callable) { + if (eval) { pbuf = &eval_buf; description = zend_make_compiled_string_description("mbregex replace" TSRMLS_CC); } else { @@ -875,22 +867,6 @@ description = NULL; } - if (is_callable) { - char *callback_name; - if (!zend_is_callable(*arg_replace_zval, 0, &callback_name TSRMLS_CC)) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name); - efree(callback_name); - MAKE_COPY_ZVAL(arg_string_zval, return_value); - RETURN_FALSE; - } - efree(callback_name); - - if (eval) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option 'e' cannot be used with replacement callback"); - RETURN_FALSE; - } - } - /* do the actual work */ err = 0; pos = (OnigUChar *)string; @@ -935,8 +911,6 @@ i += fwd; } } - - if (eval) { zval v; /* null terminate buffer */ @@ -954,38 +928,7 @@ /* Cle
[PHP-CVS] svn: /php/php-src/branches/PHP_5_4/ext/mbstring/ mbstring.c php_mbregex.c php_mbregex.h
hirokawa Sun, 25 Sep 2011 08:15:50 + Revision: http://svn.php.net/viewvc?view=revision&revision=317263 Log: MFH: added mb_ereg_replace_callback(). Changed paths: U php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c U php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c U php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.h Modified: php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c2011-09-25 08:01:54 UTC (rev 317262) +++ php/php-src/branches/PHP_5_4/ext/mbstring/mbstring.c2011-09-25 08:15:50 UTC (rev 317263) @@ -467,6 +467,13 @@ ZEND_ARG_INFO(0, string) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_ereg_replace_callback, 0, 0, 3) + ZEND_ARG_INFO(0, pattern) + ZEND_ARG_INFO(0, callback) + ZEND_ARG_INFO(0, string) + ZEND_ARG_INFO(0, option) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_mb_split, 0, 0, 2) ZEND_ARG_INFO(0, pattern) ZEND_ARG_INFO(0, string) Modified: php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c === --- php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c 2011-09-25 08:01:54 UTC (rev 317262) +++ php/php-src/branches/PHP_5_4/ext/mbstring/php_mbregex.c 2011-09-25 08:15:50 UTC (rev 317263) @@ -784,7 +784,7 @@ /* }}} */ /* {{{ _php_mb_regex_ereg_replace_exec */ -static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options) +static void _php_mb_regex_ereg_replace_exec(INTERNAL_FUNCTION_PARAMETERS, OnigOptionType options, int is_callable) { zval **arg_pattern_zval; @@ -793,9 +793,11 @@ char *replace; int replace_len; + zval **arg_replace_zval; char *string; int string_len; + zval **arg_string_zval; char *p; php_mb_regex_t *re; @@ -826,14 +828,20 @@ char *option_str = NULL; int option_str_len = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zss|s", - &arg_pattern_zval, - &replace, &replace_len, - &string, &string_len, - &option_str, &option_str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ|s", + &arg_pattern_zval, + &arg_replace_zval, + &arg_string_zval, + &option_str, &option_str_len) == FAILURE) { RETURN_FALSE; } + replace = Z_STRVAL_PP(arg_replace_zval); + replace_len = Z_STRLEN_PP(arg_replace_zval); + + string = Z_STRVAL_PP(arg_string_zval); + string_len = Z_STRLEN_PP(arg_string_zval); + if (option_str != NULL) { _php_mb_regex_init_options(option_str, option_str_len, &options, &syntax, &eval); } else { @@ -859,7 +867,7 @@ RETURN_FALSE; } - if (eval) { + if (eval || is_callable) { pbuf = &eval_buf; description = zend_make_compiled_string_description("mbregex replace" TSRMLS_CC); } else { @@ -867,6 +875,22 @@ description = NULL; } + if (is_callable) { + char *callback_name; + if (!zend_is_callable(*arg_replace_zval, 0, &callback_name TSRMLS_CC)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires argument 2, '%s', to be a valid callback", callback_name); + efree(callback_name); + MAKE_COPY_ZVAL(arg_string_zval, return_value); + RETURN_FALSE; + } + efree(callback_name); + + if (eval) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Option 'e' cannot be used with replacement callback"); + RETURN_FALSE; + } + } + /* do the actual work */ err = 0; pos = (OnigUChar *)string; @@ -911,6 +935,8 @@ i += fwd; } } + + if (eval) { zval v; /* null terminate buffer */ @@ -928,7 +954,38 @@