Fix regexec.c so $^N and $+ are correctly updated so that they work properly inside...
[p5sagit/p5-mst-13.2.git] / regexec.c
index 8144f99..6496694 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -2150,8 +2150,8 @@ got_it:
 
     if (PL_reg_eval_set)
        restore_pos(aTHX_ prog);
-    if (prog->paren_names) 
-        (void)hv_iterinit(prog->paren_names);
+    if (RXp_PAREN_NAMES(prog)) 
+        (void)hv_iterinit(RXp_PAREN_NAMES(prog));
 
     /* make sure $`, $&, $', and $digit will work later */
     if ( !(flags & REXEC_NOT_FIRST) ) {
@@ -3767,7 +3767,6 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                            const char *const p = SvPV(ret, len);
                            ret = newSVpvn_flags(p, len, SVs_TEMP);
                        }
-                       assert(!(pm_flags & RXf_UTF8));
                        rx = CALLREGCOMP(ret, pm_flags);
                        if (!(SvFLAGS(ret)
                              & (SVs_TEMP | SVs_PADTMP | SVf_READONLY
@@ -3808,8 +3807,12 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
                
                PL_regoffs = re->offs; /* essentially NOOP on GOSUB */
                
-               *PL_reglastparen = 0;
-               *PL_reglastcloseparen = 0;
+               /* see regtry, specifically PL_reglast(?:close)?paren is a pointer! (i dont know why) :dmq */
+               PL_reglastparen = &re->lastparen;
+               PL_reglastcloseparen = &re->lastcloseparen;
+               re->lastparen = 0;
+               re->lastcloseparen = 0;
+
                PL_reginput = locinput;
                PL_regsize = 0;
 
@@ -3852,6 +3855,10 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
            regcpblow(ST.cp);
            cur_eval = ST.prev_eval;
            cur_curlyx = ST.prev_curlyx;
+           
+           PL_reglastparen = &rex->lastparen;
+           PL_reglastcloseparen = &rex->lastcloseparen;
+           
            /* XXXX This is too dramatic a measure... */
            PL_reg_maxiter = 0;
             if ( nochange_depth )
@@ -3866,6 +3873,9 @@ S_regmatch(pTHX_ regmatch_info *reginfo, regnode *prog)
            SETREX(rex_sv,ST.prev_rex);
            rex = (struct regexp *)SvANY(rex_sv);
            rexi = RXi_GET(rex); 
+           PL_reglastparen = &rex->lastparen;
+           PL_reglastcloseparen = &rex->lastcloseparen;
+
            PL_reginput = locinput;
            REGCP_UNWIND(ST.lastcp);
            regcppop(rex);