summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2007-06-28 22:14:14 +0000
committerYves Orton <demerphq@gmail.com>2007-06-28 22:14:14 +0000
commit7bd1e61447493a93405e0d15fe2f8a0b6bf71de1 (patch)
tree67f21783e2a75364e18034bd688eb9cd26f0b540
parent0ac6acaed7c2092a5668c6b70ddeaf3003e989d8 (diff)
downloadperl-7bd1e61447493a93405e0d15fe2f8a0b6bf71de1.tar.gz
Replace pattern parsing logic with optree "parsing" logic.
p4raw-id: //depot/perl@31496
-rw-r--r--regcomp.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index d7b99814d6..6266ab3b4b 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -4752,6 +4752,7 @@ reStudy:
else
r->paren_names = NULL;
+#ifdef STUPID_PATTERN_CHECKS
if (r->extflags & RXf_SPLIT && r->prelen == 1 && r->precomp[0] == ' ')
/* XXX: this should happen BEFORE we compile */
r->extflags |= (RXf_SKIPWHITE|RXf_WHITE);
@@ -4759,6 +4760,20 @@ reStudy:
r->extflags |= RXf_WHITE;
else if (r->prelen == 1 && r->precomp[0] == '^')
r->extflags |= RXf_START_ONLY;
+#endif
+ if (r->extflags & RXf_SPLIT && r->prelen == 1 && r->precomp[0] == ' ')
+ /* XXX: this should happen BEFORE we compile */
+ r->extflags |= (RXf_SKIPWHITE|RXf_WHITE);
+ else {
+ regnode *first = ri->program + 1;
+ char fop = OP(first);
+ char nop = OP(NEXTOPER(first));
+
+ if (PL_regkind[fop] == BOL && nop == END)
+ r->extflags |= RXf_START_ONLY;
+ else if (fop == PLUS && nop ==SPACE && OP(regnext(first))==END)
+ r->extflags |= RXf_WHITE;
+ }
#ifdef DEBUGGING
if (RExC_paren_names) {