diff options
author | Karl Williamson <khw@cpan.org> | 2020-04-24 11:27:33 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-10-12 09:45:47 -0600 |
commit | 75ec2ec6d780e09dbf4af12c128f5e1768aa65a8 (patch) | |
tree | 539617896499b6130774424f3bcb4f02909ee475 /regcomp.c | |
parent | bfed65f5f2d2093415809b85c95155b5c26e195c (diff) | |
download | perl-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.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -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) |