summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-04-24 12:03:44 -0600
committerKarl Williamson <khw@cpan.org>2020-10-12 09:45:47 -0600
commit5ad205ab3c286bad7c6540a2c8bd53fca3c816f1 (patch)
treec0d11abee012ba05ea94a6871c6de55534624448 /regcomp.c
parentdd2cafb96f113a74d005d5cbdb410971a0588fb2 (diff)
downloadperl-5ad205ab3c286bad7c6540a2c8bd53fca3c816f1.tar.gz
regcomp.c: regpiece(): More comments; white-space
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/regcomp.c b/regcomp.c
index d98342848c..bb4bbd0a55 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12653,6 +12653,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
else { /* is '{' */
const char* endptr;
+ /* Here is a quantifier, parse for min and max values */
maxpos = NULL;
next = RExC_parse + 1;
while (isDIGIT(*next) || *next == ',') {
@@ -12755,6 +12756,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
}
+ /* 'SIMPLE' operands don't require full generality */
if ((flags&SIMPLE)) {
if (max == REG_INFTY) {
if (min == 1) {
@@ -12786,12 +12788,15 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
goto done_main_op;
}
}
+
+ /* Here, SIMPLE, but not the '*' and '+' special cases */
+
MARK_NAUGHTY_EXP(2, 2);
reginsert(pRExC_state, CURLY, ret, depth+1);
Set_Node_Offset(REGNODE_p(ret), parse_start+1); /* MJD */
Set_Node_Cur_Length(REGNODE_p(ret), parse_start);
}
- else {
+ else { /* not SIMPLE */
const regnode_offset w = reg_node(pRExC_state, WHILEM);
FLAGS(REGNODE_p(w)) = 0;
@@ -12821,6 +12826,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
MARK_NAUGHTY_EXP(1, 4); /* compound interest */
}
+ /* Finish up the CURLY/CURLYX case */
FLAGS(REGNODE_p(ret)) = 0;
ARG1_SET(REGNODE_p(ret), (U16)min);
@@ -12828,6 +12834,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
done_main_op:
+ /* Process any greediness modifiers */
if (*RExC_parse == '?') {
nextchar(pRExC_state);
reginsert(pRExC_state, MINMOD, ret, depth+1);
@@ -12849,6 +12856,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
}
+ /* Forbid extra quantifiers */
if (ISMULT2(RExC_parse)) {
RExC_parse++;
vFAIL("Nested quantifiers");