Skip to content

Commit 99d2ace

Browse files
committed
regcomp.c: Rmv unnecessary code
As spotted by Hugo van der Sanden, a barckwards reference to a capturing group doesn't need to look forward instead. If we don't have a capturing group we already should have, looking forward won't magically produce it.
1 parent 8f7b57e commit 99d2ace

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

regcomp.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11729,16 +11729,8 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp, U32 depth)
1172911729
num = RExC_npar + num;
1173011730
if (num < 1) {
1173111731

11732-
/* It might be a forward reference; we can't fail until
11733-
* we know, by completing the parse to get all the
11734-
* groups, and then reparsing */
11735-
if (ALL_PARENS_COUNTED) {
11736-
RExC_parse++;
11732+
RExC_parse++;
1173711733
vFAIL(non_existent_group_msg);
11738-
}
11739-
else {
11740-
REQUIRE_PARENS_PASS;
11741-
}
1174211734
}
1174311735
} else if ( paren == '+' ) {
1174411736
num = RExC_npar + num - 1;

t/re/pat_advanced.t

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2532,6 +2532,13 @@ EOF
25322532
"", {}, "EXACTFUP node isn't changed into something else");
25332533
}
25342534

2535+
{
2536+
fresh_perl_is('qr/((?-2147483647))/',
2537+
"Reference to nonexistent group in regex; marked by <--"
2538+
. " HERE in m/((?-2147483647) <-- HERE )/ at - line 1.",
2539+
{}, "Large negative relative capture group");
2540+
}
2541+
25352542

25362543
# !!! NOTE that tests that aren't at all likely to crash perl should go
25372544
# a ways above, above these last ones. There's a comment there that, like

0 commit comments

Comments
 (0)