(IV)(cp), (IV)PL_savestack_ix)); \
regcpblow(cp)
+#define UNWIND_PAREN(lp, lcp) \
+ for (n = rex->lastparen; n > lp; n--) \
+ rex->offs[n].end = -1; \
+ rex->lastparen = n; \
+ rex->lastcloseparen = lcp;
+
+
STATIC void
S_regcppop(pTHX_ regexp *rex)
{
case TRIE_next_fail: /* we failed - try next alternative */
if ( ST.jump) {
REGCP_UNWIND(ST.cp);
- for (n = rex->lastparen; n > ST.lastparen; n--)
- rex->offs[n].end = -1;
- rex->lastparen = n;
- rex->lastcloseparen = ST.lastcloseparen;
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
}
if (!--ST.accepted) {
DEBUG_EXECUTE_r({
no_final = 0;
}
REGCP_UNWIND(ST.cp);
- for (n = rex->lastparen; n > ST.lastparen; n--)
- rex->offs[n].end = -1;
- rex->lastparen = n;
- rex->lastcloseparen = ST.lastcloseparen;
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
scan = ST.next_branch;
/* no more branches? */
if (!scan || (OP(scan) != BRANCH && OP(scan) != BRANCHJ)) {
case CURLYM_B_fail: /* just failed to match a B */
REGCP_UNWIND(ST.cp);
- rex->lastparen = ST.lastparen;
- rex->lastcloseparen = ST.lastcloseparen;
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
if (ST.minmod) {
I32 max = ARG2(ST.me);
if (max != REG_INFTY && ST.count == max)
PL_reginput = locinput; /* Could be reset... */
REGCP_UNWIND(ST.cp);
+ if (ST.paren) {
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
+ }
/* Couldn't or didn't -- move forward. */
ST.oldloc = locinput;
if (utf8_target)
/* failed to find B in a non-greedy match where c1,c2 invalid */
REGCP_UNWIND(ST.cp);
+ if (ST.paren) {
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
+ }
/* failed -- move forward one */
PL_reginput = locinput;
if (regrepeat(rex, ST.A, 1, depth)) {
/* failed to find B in a greedy match */
REGCP_UNWIND(ST.cp);
+ if (ST.paren) {
+ UNWIND_PAREN(ST.lastparen, ST.lastcloseparen);
+ }
/* back up. */
if (--ST.count < ST.min)
sayNO;
/^(??{"s"})$/iaa \x{17F} n - -
/^(??{'\w'})$/u \x{AA} y - -
+# #113670 ensure any captures to the right are invalidated when CURLY
+# and CURLYM backtrack
+
+^(?:(X)?(\d)|(X)?(\d\d))$ X12 y $1-$2-$3-$4 --X-12
+^(?:(XX)?(\d)|(XX)?(\d\d))$ XX12 y $1-$2-$3-$4 --XX-12
+
# vim: softtabstop=0 noexpandtab