summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2013-06-22 18:17:09 +0200
committerYves Orton <demerphq@gmail.com>2013-06-22 18:42:01 +0200
commitb8f6efdd9cee0ae5cd4adf5a15aebb2984f57fda (patch)
tree589b95a5eb84811c08a9b4ed6993899c21624ca8 /regcomp.c
parent337ff3078c4082e843af19536e11f70d3d14bfe9 (diff)
downloadperl-b8f6efdd9cee0ae5cd4adf5a15aebb2984f57fda.tar.gz
Fix and add tests for *PRUNE/*THEN plus leading non-greedy +
"aaabc" should match /a+?(*THEN)bc/ with "abc".
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index 3cb7829c4e..d7c5b00d91 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -5521,6 +5521,8 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
I32 sawlookahead = 0;
I32 sawplus = 0;
I32 sawopen = 0;
+ I32 sawminmod = 0;
+
regex_charset initial_charset = get_regex_charset(orig_rx_flags);
bool recompile = 0;
bool runtime_code = 0;
@@ -6029,7 +6031,7 @@ Perl_re_op_compile(pTHX_ SV ** const patternp, int pat_count,
}
reStudy:
- r->minlen = minlen = sawlookahead = sawplus = sawopen = 0;
+ r->minlen = minlen = sawlookahead = sawplus = sawopen = sawminmod = 0;
Zero(r->substrs, 1, struct reg_substr_data);
#ifdef TRIE_STUDY_OPT
@@ -6098,12 +6100,15 @@ reStudy:
* the only op that could be a regnode is PLUS, all the rest
* will be regnode_1 or regnode_2.
*
+ * (yves doesn't think this is true)
*/
if (OP(first) == PLUS)
sawplus = 1;
- else
+ else {
+ if (OP(first) == MINMOD)
+ sawminmod = 1;
first += regarglen[OP(first)];
-
+ }
first = NEXTOPER(first);
first_next= regnext(first);
}
@@ -6174,7 +6179,7 @@ reStudy:
first = NEXTOPER(first);
goto again;
}
- if (sawplus && !sawlookahead && (!sawopen || !RExC_sawback)
+ if (sawplus && !sawminmod && !sawlookahead && (!sawopen || !RExC_sawback)
&& !pRExC_state->num_code_blocks) /* May examine pos and $& */
/* x+ must match at the 1st pos of run of x's */
r->intflags |= PREGf_SKIP;