summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-11-01 14:49:35 -0700
committerFather Chrysostomos <sprout@cpan.org>2012-11-01 18:10:00 -0700
commit99543f15a007c8878501777ac5d75c1bbaef03b4 (patch)
tree1160edc73414f7ad13d957b8b67798bfe9d4d4e5 /regcomp.c
parent24044fabd839afe7d01d53cc50f06415298d31ec (diff)
downloadperl-99543f15a007c8878501777ac5d75c1bbaef03b4.tar.gz
Fix /a++(?{})+$code_block/
This I would expect: $ perl5.16.0 -wMre=eval -e '$x = "(?{})"; /a++(?{})+$x/x' (?{})+ matches null string many times in regex; marked by <-- HERE in m/a++(?{})+ <-- HERE (?{})/ at -e line 1. Use of uninitialized value $_ in pattern match (m//) at -e line 1. It warns, but it still runs. This I would not, $ perl5.17.5 -wMre=eval -e '$x = "(?{})"; /a++(?{})+$x/x' Nested quantifiers in regex; marked by <-- HERE in m/a++ + <-- HERE (?{})/ at (eval 1) line 1. were it not for the fact that I know how it works. :-) To compile the blocks in $x without recompiling the blocks directly inside /.../, the regexp compiler blanks out the ‘outer’ blocks with spaces, and compiles qr'a++ +(?{})'x. But /x can see through those spaces, resulting in a change in behaviour. So use under- scores instead.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/regcomp.c b/regcomp.c
index 3bd847568d..4979b6a85e 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5005,7 +5005,7 @@ S_has_runtime_code(pTHX_ RExC_state_t * const pRExC_state, OP *expr,
*
* becomes
*
- * qr'a\\bc def\'ghi\\\\jkl(?{"this is runtime"})mno'
+ * qr'a\\bc_______________________def\'ghi\\\\jkl(?{"this is runtime"})mno'
*
* After eval_sv()-ing that, grab any new code blocks from the returned qr
* and merge them with any code blocks of the original regexp.
@@ -5058,7 +5058,7 @@ S_compile_runtime_code(pTHX_ RExC_state_t * const pRExC_state,
/* blank out literal code block */
assert(pat[s] == '(');
while (s <= pRExC_state->code_blocks[n].end) {
- *p++ = ' ';
+ *p++ = '_';
s++;
}
s--;