Document that ${^TAINT} is read-only.
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 6b35e39..6ecb978 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1270,6 +1270,8 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                        l -= old;
                        /* Get the added string: */
                        last_str = newSVpvn(s  + old, l);
+                       if (UTF)
+                           SvUTF8_on(last_str);
                        if (deltanext == 0 && pos_before == b) {
                            /* What was added is a constant string */
                            if (mincount > 1) {
@@ -5018,20 +5020,6 @@ S_re_croak2(pTHX_ const char* pat1,const char* pat2,...)
 void
 Perl_save_re_context(pTHX)
 {
-#if 0
-    SAVEPPTR(RExC_precomp);            /* uncompiled string. */
-    SAVEI32(RExC_npar);                /* () count. */
-    SAVEI32(RExC_size);                /* Code size. */
-    SAVEI32(RExC_flags);               /* are we folding, multilining? */
-    SAVEVPTR(RExC_rx);         /* from regcomp.c */
-    SAVEI32(RExC_seen);                /* from regcomp.c */
-    SAVEI32(RExC_sawback);             /* Did we see \1, ...? */
-    SAVEI32(RExC_naughty);             /* How bad is this pattern? */
-    SAVEVPTR(RExC_emit);               /* Code-emit pointer; &regdummy = don't */
-    SAVEPPTR(RExC_end);                /* End of input for compile */
-    SAVEPPTR(RExC_parse);              /* Input-scan pointer. */
-#endif
-
     SAVEI32(PL_reg_flags);             /* from regexec.c */
     SAVEPPTR(PL_bostr);
     SAVEPPTR(PL_reginput);             /* String-input pointer. */
@@ -5040,6 +5028,7 @@ Perl_save_re_context(pTHX)
     SAVEVPTR(PL_regstartp);            /* Pointer to startp array. */
     SAVEVPTR(PL_regendp);              /* Ditto for endp. */
     SAVEVPTR(PL_reglastparen);         /* Similarly for lastparen. */
+    SAVEVPTR(PL_reglastcloseparen);    /* Similarly for lastcloseparen. */
     SAVEPPTR(PL_regtill);              /* How far we are required to go. */
     SAVEGENERICPV(PL_reg_start_tmp);           /* from regexec.c */
     PL_reg_start_tmp = 0;
@@ -5056,13 +5045,43 @@ Perl_save_re_context(pTHX)
     SAVEVPTR(PL_reg_re);               /* from regexec.c */
     SAVEPPTR(PL_reg_ganch);            /* from regexec.c */
     SAVESPTR(PL_reg_sv);               /* from regexec.c */
-    SAVEI8(PL_reg_match_utf8);         /* from regexec.c */
+    SAVEBOOL(PL_reg_match_utf8);       /* from regexec.c */
     SAVEVPTR(PL_reg_magic);            /* from regexec.c */
     SAVEI32(PL_reg_oldpos);                    /* from regexec.c */
     SAVEVPTR(PL_reg_oldcurpm);         /* from regexec.c */
     SAVEVPTR(PL_reg_curpm);            /* from regexec.c */
+    SAVEPPTR(PL_reg_oldsaved);         /* old saved substr during match */
+    PL_reg_oldsaved = Nullch;
+    SAVEI32(PL_reg_oldsavedlen);       /* old length of saved substr during match */
+    PL_reg_oldsavedlen = 0;
+    SAVEI32(PL_reg_maxiter);           /* max wait until caching pos */
+    PL_reg_maxiter = 0;
+    SAVEI32(PL_reg_leftiter);          /* wait until caching pos */
+    PL_reg_leftiter = 0;
+    SAVEGENERICPV(PL_reg_poscache);    /* cache of pos of WHILEM */
+    PL_reg_poscache = Nullch;
+    SAVEI32(PL_reg_poscache_size);     /* size of pos cache of WHILEM */
+    PL_reg_poscache_size = 0;
+    SAVEPPTR(PL_regprecomp);           /* uncompiled string. */
     SAVEI32(PL_regnpar);               /* () count. */
     SAVEI32(PL_regsize);               /* from regexec.c */
+
+    {
+       /* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
+       U32 i;
+       GV *mgv;
+       REGEXP *rx;
+       char digits[16];
+
+       if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
+           for (i = 1; i <= rx->nparens; i++) {
+               sprintf(digits, "%lu", (long)i);
+               if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV)))
+                   save_scalar(mgv);
+           }
+       }
+    }
+
 #ifdef DEBUGGING
     SAVEPPTR(PL_reg_starttry);         /* from regexec.c */
 #endif