diff options
author | Andrei Zmievski <andrei@php.net> | 2006-04-06 21:10:45 +0000 |
---|---|---|
committer | Andrei Zmievski <andrei@php.net> | 2006-04-06 21:10:45 +0000 |
commit | d288f66c7cc2ff00fffaea78fa8ee184e2c4652b (patch) | |
tree | c9118926a5d84c68d429bc320a1f454fbad11b79 | |
parent | ad7768ee63d8273d58f0d81222f38a0aa4c1236b (diff) | |
download | php-git-d288f66c7cc2ff00fffaea78fa8ee184e2c4652b.tar.gz |
Fix a bug that would not fill in the fifth argument to preg_replace()
properly, if the variable was not declared previously.
-rw-r--r-- | Zend/zend_arg_defs.c | 8 | ||||
-rw-r--r-- | Zend/zend_modules.h | 1 | ||||
-rw-r--r-- | ext/pcre/TODO | 20 | ||||
-rw-r--r-- | ext/pcre/php_pcre.c | 11 |
4 files changed, 31 insertions, 9 deletions
diff --git a/Zend/zend_arg_defs.c b/Zend/zend_arg_defs.c index f1ce13a452..be0601c9c8 100644 --- a/Zend/zend_arg_defs.c +++ b/Zend/zend_arg_defs.c @@ -40,6 +40,14 @@ ZEND_BEGIN_ARG_INFO(fourth_arg_force_ref, 0) ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); +ZEND_BEGIN_ARG_INFO(fifth_arg_force_ref, 0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) +ZEND_END_ARG_INFO(); + ZEND_BEGIN_ARG_INFO(all_args_by_ref, 1) ZEND_END_ARG_INFO(); diff --git a/Zend/zend_modules.h b/Zend/zend_modules.h index 8be64b5b01..57a38a82bb 100644 --- a/Zend/zend_modules.h +++ b/Zend/zend_modules.h @@ -36,6 +36,7 @@ extern struct _zend_arg_info first_arg_force_ref[2]; extern struct _zend_arg_info second_arg_force_ref[3]; extern struct _zend_arg_info third_arg_force_ref[4]; extern struct _zend_arg_info fourth_arg_force_ref[5]; +extern struct _zend_arg_info fifth_arg_force_ref[6]; extern struct _zend_arg_info all_args_by_ref[1]; #define ZEND_MODULE_API_NO 20050922 diff --git a/ext/pcre/TODO b/ext/pcre/TODO new file mode 100644 index 0000000000..1000c64105 --- /dev/null +++ b/ext/pcre/TODO @@ -0,0 +1,20 @@ +- Allow NULL for $matches argument (helps when using preg_match only for + match condition) - might not be possible + +- http://bugs.php.net/bug.php?id=36975 + +- I'd love to see a pattern modifer which says "don't fill $matches except + for the overall match and any specific named captures". This would allow + (?: ...) to be avoided in a lot of cases. + + This could make for non-trivial speed enhancements with regexes that have + a lot of parens when working on long strings, since you'd not have to + copy them multiple times to the $matches array. + + Also, it makes $matches much cleaner after a match where you've named the + captures you're interested in. + + (Note that this would not involve the use of PCRE_NO_AUTO_CAPTURE, as + that would change the semantics of backreferences) + + diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 557898abf3..6cd6d27a29 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -18,13 +18,6 @@ /* $Id$ */ -/* - * TODO - * - * - Allow NULL for $matches argument (helps when using preg_match only for - * match condition) - */ - #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -1622,8 +1615,8 @@ PHP_FUNCTION(preg_grep) zend_function_entry pcre_functions[] = { PHP_FE(preg_match, third_arg_force_ref) PHP_FE(preg_match_all, third_arg_force_ref) - PHP_FE(preg_replace, NULL) - PHP_FE(preg_replace_callback, NULL) + PHP_FE(preg_replace, fifth_arg_force_ref) + PHP_FE(preg_replace_callback, fifth_arg_force_ref) PHP_FE(preg_split, NULL) PHP_FE(preg_quote, NULL) PHP_FE(preg_grep, NULL) |