Skip to content

Commit 02853b7

Browse files
committed
implicitly anchor .{0,} like .* [perl #125810]
1 parent bbac6b2 commit 02853b7

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

regcomp.c

+15-13
Original file line numberDiff line numberDiff line change
@@ -10912,6 +10912,20 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1091210912

1091310913
do_curly:
1091410914
if ((flags&SIMPLE)) {
10915+
if (min == 0 && max == REG_INFTY) {
10916+
reginsert(pRExC_state, STAR, ret, depth+1);
10917+
ret->flags = 0;
10918+
MARK_NAUGHTY(4);
10919+
RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
10920+
goto nest_check;
10921+
}
10922+
if (min == 1 && max == REG_INFTY) {
10923+
reginsert(pRExC_state, PLUS, ret, depth+1);
10924+
ret->flags = 0;
10925+
MARK_NAUGHTY(3);
10926+
RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
10927+
goto nest_check;
10928+
}
1091510929
MARK_NAUGHTY_EXP(2, 2);
1091610930
reginsert(pRExC_state, CURLY, ret, depth+1);
1091710931
Set_Node_Offset(ret, parse_start+1); /* MJD */
@@ -10985,22 +10999,10 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
1098510999

1098611000
*flagp = (op != '+') ? (WORST|SPSTART|HASWIDTH) : (WORST|HASWIDTH);
1098711001

10988-
if (op == '*' && (flags&SIMPLE)) {
10989-
reginsert(pRExC_state, STAR, ret, depth+1);
10990-
ret->flags = 0;
10991-
MARK_NAUGHTY(4);
10992-
RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
10993-
}
10994-
else if (op == '*') {
11002+
if (op == '*') {
1099511003
min = 0;
1099611004
goto do_curly;
1099711005
}
10998-
else if (op == '+' && (flags&SIMPLE)) {
10999-
reginsert(pRExC_state, PLUS, ret, depth+1);
11000-
ret->flags = 0;
11001-
MARK_NAUGHTY(3);
11002-
RExC_seen |= REG_UNBOUNDED_QUANTIFIER_SEEN;
11003-
}
1100411006
else if (op == '+') {
1100511007
min = 1;
1100611008
goto do_curly;

0 commit comments

Comments
 (0)