summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-04-24 11:27:33 -0600
committerKarl Williamson <khw@cpan.org>2020-10-12 09:45:47 -0600
commit75ec2ec6d780e09dbf4af12c128f5e1768aa65a8 (patch)
tree539617896499b6130774424f3bcb4f02909ee475 /regcomp.c
parentbfed65f5f2d2093415809b85c95155b5c26e195c (diff)
downloadperl-75ec2ec6d780e09dbf4af12c128f5e1768aa65a8.tar.gz
regcomp.c: regpiece() 0 times anything is 0
Prior to this commit, regpiece() gave width to many quantified values. This is wrong. If something is zero width, repeating it doesn't cause it to gain width. I don't know if this led to wrong pattern matching results, but I imagine it led to slower results in some cases.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index 945e444a31..ed1cb92623 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -12640,8 +12640,6 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
if (op != '{') {
nextchar(pRExC_state);
- *flagp = HASWIDTH;
-
if (op == '*') {
min = 0;
}
@@ -12748,6 +12746,9 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
}
+ if (max > 0)
+ *flagp |= (flags & HASWIDTH);
+
if ((flags&SIMPLE)) {
if (min == 0 && max == REG_INFTY) {
@@ -12814,10 +12815,6 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
}
FLAGS(REGNODE_p(ret)) = 0;
- if (min > 0)
- *flagp = 0;
- if (max > 0)
- *flagp |= HASWIDTH;
ARG1_SET(REGNODE_p(ret), (U16)min);
ARG2_SET(REGNODE_p(ret), (U16)max);
if (max == REG_INFTY)