Skip to content

Commit e4105e8

Browse files
committed
Improve regex debug output for unbounded curly quantifiers
A regex like /^a{5,}\z/ will match any string consisting exactly of 5 or more "a" characters, but under debugging, the quantifier was previously displayed as the numeric value of REG_INFTY (usually 32767). This commit causes the upper bound to be displayed as "INFTY".
1 parent bdc4e4b commit e4105e8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

regcomp.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -17002,9 +17002,15 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o, const regmatch_
1700217002
}
1700317003

1700417004
} else if (k == CURLY) {
17005+
U32 lo = ARG1(o), hi = ARG2(o);
1700517006
if (OP(o) == CURLYM || OP(o) == CURLYN || OP(o) == CURLYX)
1700617007
Perl_sv_catpvf(aTHX_ sv, "[%d]", o->flags); /* Parenth number */
17007-
Perl_sv_catpvf(aTHX_ sv, " {%d,%d}", ARG1(o), ARG2(o));
17008+
Perl_sv_catpvf(aTHX_ sv, "{%d,", lo);
17009+
if (hi == REG_INFTY)
17010+
sv_catpvs(sv, "INFTY");
17011+
else
17012+
Perl_sv_catpvf(aTHX_ sv, "%d", hi);
17013+
sv_catpvs(sv, "}");
1700817014
}
1700917015
else if (k == WHILEM && o->flags) /* Ordinal/of */
1701017016
Perl_sv_catpvf(aTHX_ sv, "[%d/%d]", o->flags & 0xf, o->flags>>4);

0 commit comments

Comments
 (0)