We no longer need PL_shared_hek_table
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 8c1abc5..02cece8 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -307,7 +307,7 @@ static const scan_data_t zero_scan_data =
  * Simple_vFAIL -- like FAIL, but marks the current location in the scan
  */
 #define        Simple_vFAIL(m) STMT_START {                                    \
-    IV offset = RExC_parse - RExC_precomp;                             \
+    const IV offset = RExC_parse - RExC_precomp;                       \
     Perl_croak(aTHX_ "%s" REPORT_LOCATION,                             \
            m, (int)offset, RExC_precomp, RExC_precomp + offset);       \
 } STMT_END
@@ -325,7 +325,7 @@ static const scan_data_t zero_scan_data =
  * Like Simple_vFAIL(), but accepts two arguments.
  */
 #define        Simple_vFAIL2(m,a1) STMT_START {                        \
-    IV offset = RExC_parse - RExC_precomp;                     \
+    const IV offset = RExC_parse - RExC_precomp;                       \
     S_re_croak2(aTHX_ m, REPORT_LOCATION, a1,                  \
            (int)offset, RExC_precomp, RExC_precomp + offset);  \
 } STMT_END
@@ -344,7 +344,7 @@ static const scan_data_t zero_scan_data =
  * Like Simple_vFAIL(), but accepts three arguments.
  */
 #define        Simple_vFAIL3(m, a1, a2) STMT_START {                   \
-    IV offset = RExC_parse - RExC_precomp;                     \
+    const IV offset = RExC_parse - RExC_precomp;               \
     S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2,              \
            (int)offset, RExC_precomp, RExC_precomp + offset);  \
 } STMT_END
@@ -362,29 +362,19 @@ static const scan_data_t zero_scan_data =
  * Like Simple_vFAIL(), but accepts four arguments.
  */
 #define        Simple_vFAIL4(m, a1, a2, a3) STMT_START {               \
-    IV offset = RExC_parse - RExC_precomp;                     \
+    const IV offset = RExC_parse - RExC_precomp;               \
     S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3,          \
            (int)offset, RExC_precomp, RExC_precomp + offset);  \
 } STMT_END
 
-/*
- * Like Simple_vFAIL(), but accepts five arguments.
- */
-#define        Simple_vFAIL5(m, a1, a2, a3, a4) STMT_START {           \
-    IV offset = RExC_parse - RExC_precomp;                     \
-    S_re_croak2(aTHX_ m, REPORT_LOCATION, a1, a2, a3, a4,      \
-           (int)offset, RExC_precomp, RExC_precomp + offset);  \
-} STMT_END
-
-
 #define        vWARN(loc,m) STMT_START {                                       \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN(WARN_REGEXP), "%s" REPORT_LOCATION,     \
            m, (int)offset, RExC_precomp, RExC_precomp + offset);       \
 } STMT_END
 
 #define        vWARNdep(loc,m) STMT_START {                                    \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_REGEXP),         \
            "%s" REPORT_LOCATION,                                       \
            m, (int)offset, RExC_precomp, RExC_precomp + offset);       \
@@ -392,25 +382,25 @@ static const scan_data_t zero_scan_data =
 
 
 #define        vWARN2(loc, m, a1) STMT_START {                                 \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION,                \
            a1, (int)offset, RExC_precomp, RExC_precomp + offset);      \
 } STMT_END
 
 #define        vWARN3(loc, m, a1, a2) STMT_START {                             \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION,                \
            a1, a2, (int)offset, RExC_precomp, RExC_precomp + offset);  \
 } STMT_END
 
 #define        vWARN4(loc, m, a1, a2, a3) STMT_START {                         \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION,                \
            a1, a2, a3, (int)offset, RExC_precomp, RExC_precomp + offset); \
 } STMT_END
 
 #define        vWARN5(loc, m, a1, a2, a3, a4) STMT_START {                     \
-    IV offset = loc - RExC_precomp;                                    \
+    const IV offset = loc - RExC_precomp;                              \
     Perl_warner(aTHX_ packWARN(WARN_REGEXP), m REPORT_LOCATION,                \
            a1, a2, a3, a4, (int)offset, RExC_precomp, RExC_precomp + offset); \
 } STMT_END
@@ -507,8 +497,8 @@ S_scan_commit(pTHX_ RExC_state_t *pRExC_state, scan_data_t *data)
     }
     SvCUR_set(data->last_found, 0);
     {
-       SV * sv = data->last_found;
-       MAGIC *mg =
+       SV * const sv = data->last_found;
+       MAGIC * const mg =
            SvUTF8(sv) && SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_utf8) : NULL;
        if (mg && mg->mg_len > 0)
            mg->mg_len = 0;
@@ -530,7 +520,7 @@ S_cl_anything(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *c
 
 /* Can match anything (initialization) */
 STATIC int
-S_cl_is_anything(pTHX_ struct regnode_charclass_class *cl)
+S_cl_is_anything(pTHX_ const struct regnode_charclass_class *cl)
 {
     int value;
 
@@ -567,7 +557,7 @@ S_cl_init_zero(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *
 /* We assume that cl is not inverted */
 STATIC void
 S_cl_and(pTHX_ struct regnode_charclass_class *cl,
-        struct regnode_charclass_class *and_with)
+       const struct regnode_charclass_class *and_with)
 {
     if (!(and_with->flags & ANYOF_CLASS)
        && !(cl->flags & ANYOF_CLASS)
@@ -603,7 +593,7 @@ S_cl_and(pTHX_ struct regnode_charclass_class *cl,
 /* 'OR' a given class with another one.  Can create false positives */
 /* We assume that cl is not inverted */
 STATIC void
-S_cl_or(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, struct regnode_charclass_class *or_with)
+S_cl_or(pTHX_ RExC_state_t *pRExC_state, struct regnode_charclass_class *cl, const struct regnode_charclass_class *or_with)
 {
     if (or_with->flags & ANYOF_INVERT) {
        /* We do not use
@@ -899,7 +889,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
     for ( cur = first ; cur < last ; cur = regnext( cur ) ) {
         regnode *noper = NEXTOPER( cur );
         const U8 *uc = (U8*)STRING( noper );
-        const U8 *e  = uc + STR_LEN( noper );
+        const U8 * const e  = uc + STR_LEN( noper );
         STRLEN foldlen = 0;
         U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ];
         const U8 *scan = (U8*)NULL;
@@ -987,7 +977,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
 
         regnode *noper   = NEXTOPER( cur );
         U8 *uc           = (U8*)STRING( noper );
-        U8 *e            = uc + STR_LEN( noper );
+        const U8 * const e = uc + STR_LEN( noper );
         U32 state        = 1;         /* required init */
         U16 charid       = 0;         /* sanity init */
         U8 *scan         = (U8*)NULL; /* sanity init */
@@ -1024,14 +1014,13 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
                         newstate = TRIE_LIST_ITEM( state, check ).newstate;
                         break;
                     }
-                    }
-                    if ( ! newstate ) {
-                        newstate = next_alloc++;
-                        TRIE_LIST_PUSH( state, charid, newstate );
-                        transcount++;
-                    }
-                    state = newstate;
-
+               }
+               if ( ! newstate ) {
+                   newstate = next_alloc++;
+                   TRIE_LIST_PUSH( state, charid, newstate );
+                   transcount++;
+               }
+               state = newstate;
             } else {
                 Perl_croak( aTHX_ "panic! In trie construction, no char mapping for %"IVdf, uvc );
             }
@@ -1060,16 +1049,14 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
 
         DEBUG_TRIE_COMPILE_MORE_r({
             U32 state;
-            U16 charid;
 
-            /*
-               print out the table precompression.
-             */
+            /* print out the table precompression.  */
 
             PerlIO_printf( Perl_debug_log, "\nState :Word | Transition Data\n" );
             PerlIO_printf( Perl_debug_log,   "------:-----+-----------------" );
 
             for( state=1 ; state < next_alloc ; state ++ ) {
+               U16 charid;
 
                 PerlIO_printf( Perl_debug_log, "\n %04"UVXf" :", (UV)state  );
                 if ( ! trie->states[ state ].wordnum ) {
@@ -1082,7 +1069,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
                 for( charid = 1 ; charid <= TRIE_LIST_USED( state ) ; charid++ ) {
                     SV **tmp = av_fetch( trie->revcharmap, TRIE_LIST_ITEM(state,charid).forid, 0);
                     PerlIO_printf( Perl_debug_log, "%s:%3X=%04"UVXf" | ",
-                        SvPV_nolen( *tmp ),
+                        SvPV_nolen_const( *tmp ),
                         TRIE_LIST_ITEM(state,charid).forid,
                         (UV)TRIE_LIST_ITEM(state,charid).newstate
                     );
@@ -1095,7 +1082,6 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
         Newz( 848203, trie->trans, transcount ,reg_trie_trans );
         {
             U32 state;
-            U16 idx;
             U32 tp = 0;
             U32 zp = 0;
 
@@ -1112,7 +1098,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
                 if (trie->states[state].trans.list) {
                     U16 minid=TRIE_LIST_ITEM( state, 1).forid;
                     U16 maxid=minid;
-
+                   U16 idx;
 
                     for( idx = 2 ; idx <= TRIE_LIST_USED( state ) ; idx++ ) {
                         if ( TRIE_LIST_ITEM( state, idx).forid < minid ) {
@@ -1208,8 +1194,8 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
         for ( cur = first ; cur < last ; cur = regnext( cur ) ) {
 
             regnode *noper   = NEXTOPER( cur );
-            U8 *uc           = (U8*)STRING( noper );
-            U8 *e            = uc + STR_LEN( noper );
+           const U8 *uc     = (U8*)STRING( noper );
+           const U8 * const e = uc + STR_LEN( noper );
 
             U32 state        = 1;         /* required init */
 
@@ -1280,7 +1266,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
             for( charid = 0 ; charid < trie->uniquecharcount ; charid++ ) {
                 SV **tmp = av_fetch( trie->revcharmap, charid, 0);
                 if ( tmp ) {
-                  PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen( *tmp ) );
+                  PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen_const( *tmp ) );
                 }
             }
 
@@ -1371,15 +1357,15 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
            demq
         */
         const U32 laststate = TRIE_NODENUM( next_alloc );
-        U32 used , state, charid;
+       U32 state, charid;
         U32 pos = 0, zp=0;
         trie->laststate = laststate;
 
         for ( state = 1 ; state < laststate ; state++ ) {
             U8 flag = 0;
-            U32 stateidx = TRIE_NODEIDX( state );
-            U32 o_used=trie->trans[ stateidx ].check;
-            used = trie->trans[ stateidx ].check;
+           const U32 stateidx = TRIE_NODEIDX( state );
+           const U32 o_used = trie->trans[ stateidx ].check;
+           U32 used = trie->trans[ stateidx ].check;
             trie->trans[ stateidx ].check = 0;
 
             for ( charid = 0 ; used && charid < trie->uniquecharcount ; charid++ ) {
@@ -1437,7 +1423,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
         for( state = 0 ; state < trie->uniquecharcount ; state++ ) {
             SV **tmp = av_fetch( trie->revcharmap, state, 0);
             if ( tmp ) {
-              PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen( *tmp ) );
+              PerlIO_printf( Perl_debug_log, "%4.4s ", SvPV_nolen_const( *tmp ) );
             }
         }
         PerlIO_printf( Perl_debug_log, "\n-----:-----------------------");
@@ -1447,7 +1433,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
         PerlIO_printf( Perl_debug_log, "\n");
 
         for( state = 1 ; state < trie->laststate ; state++ ) {
-            U32 base = trie->states[ state ].trans.base;
+           const U32 base = trie->states[ state ].trans.base;
 
             PerlIO_printf( Perl_debug_log, "#%04"UVXf" ", (UV)state);
 
@@ -1578,7 +1564,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
          SV *mysv=sv_newmortal();
          regprop( mysv, scan);
          PerlIO_printf(Perl_debug_log, "%*speep: %s (0x%08"UVXf")\n",
-           (int)depth*2, "", SvPV_nolen(mysv), PTR2UV(scan));
+           (int)depth*2, "", SvPV_nolen_const(mysv), PTR2UV(scan));
        });
 
        if (PL_regkind[(U8)OP(scan)] == EXACT) {
@@ -1656,8 +1642,8 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
 */
                 char *s0 = STRING(scan), *s, *t;
                 char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4;
-                 const char *t0 = "\xcc\x88\xcc\x81";
-                 const char *t1 = t0 + 3;
+                const char * const t0 = "\xcc\x88\xcc\x81";
+                const char * const t1 = t0 + 3;
 
                 for (s = s0 + 2;
                      s < s2 && (t = ninstr(s, s1, t0, t1));
@@ -1872,7 +1858,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                         DEBUG_OPTIMISE_r({
                             regprop( mysv, tail );
                             PerlIO_printf( Perl_debug_log, "%*s%s%s%s\n",
-                                (int)depth * 2 + 2, "", "Tail node is:", SvPV_nolen( mysv ),
+                                (int)depth * 2 + 2, "", "Tail node is:", SvPV_nolen_const( mysv ),
                                 (RExC_seen_evals) ? "[EVAL]" : ""
                             );
                         });
@@ -1909,16 +1895,16 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                             DEBUG_OPTIMISE_r({
                                 regprop( mysv, cur);
                                 PerlIO_printf( Perl_debug_log, "%*s%s",
-                                   (int)depth * 2 + 2,"  ", SvPV_nolen( mysv ) );
+                                   (int)depth * 2 + 2,"  ", SvPV_nolen_const( mysv ) );
 
                                 regprop( mysv, noper);
                                 PerlIO_printf( Perl_debug_log, " -> %s",
-                                    SvPV_nolen(mysv));
+                                    SvPV_nolen_const(mysv));
 
                                 if ( noper_next ) {
                                   regprop( mysv, noper_next );
                                   PerlIO_printf( Perl_debug_log,"\t=> %s\t",
-                                    SvPV_nolen(mysv));
+                                    SvPV_nolen_const(mysv));
                                 }
                                 PerlIO_printf( Perl_debug_log, "0x%p,0x%p,0x%p)\n",
                                    first, last, cur );
@@ -1936,20 +1922,20 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                                         if (!last ) {
                                             regprop( mysv, first);
                                             PerlIO_printf( Perl_debug_log, "%*s%s",
-                                              (int)depth * 2 + 2, "F:", SvPV_nolen( mysv ) );
+                                              (int)depth * 2 + 2, "F:", SvPV_nolen_const( mysv ) );
                                             regprop( mysv, NEXTOPER(first) );
                                             PerlIO_printf( Perl_debug_log, " -> %s\n",
-                                              SvPV_nolen( mysv ) );
+                                              SvPV_nolen_const( mysv ) );
                                         }
                                     );
                                     last = cur;
                                     DEBUG_OPTIMISE_r({
                                         regprop( mysv, cur);
                                         PerlIO_printf( Perl_debug_log, "%*s%s",
-                                          (int)depth * 2 + 2, "N:", SvPV_nolen( mysv ) );
+                                          (int)depth * 2 + 2, "N:", SvPV_nolen_const( mysv ) );
                                         regprop( mysv, noper );
                                         PerlIO_printf( Perl_debug_log, " -> %s\n",
-                                          SvPV_nolen( mysv ) );
+                                          SvPV_nolen_const( mysv ) );
                                     });
                                 }
                             } else {
@@ -1978,7 +1964,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                             regprop( mysv, cur);
                             PerlIO_printf( Perl_debug_log,
                               "%*s%s\t(0x%p,0x%p,0x%p)\n", (int)depth * 2 + 2,
-                              "  ", SvPV_nolen( mysv ), first, last, cur);
+                              "  ", SvPV_nolen_const( mysv ), first, last, cur);
 
                         });
                         if ( last ) {
@@ -2017,7 +2003,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                sv_catpvn(data->last_found, STRING(scan), STR_LEN(scan));
                {
                    SV * sv = data->last_found;
-                   MAGIC *mg = SvUTF8(sv) && SvMAGICAL(sv) ?
+                   MAGIC * const mg = SvUTF8(sv) && SvMAGICAL(sv) ?
                        mg_find(sv, PERL_MAGIC_utf8) : NULL;
                    if (mg && mg->mg_len >= 0)
                        mg->mg_len += utf8_length((U8*)STRING(scan),
@@ -2355,7 +2341,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
 #if defined(SPARC64_GCC_WORKAROUND)
                        I32 b = 0;
                        STRLEN l = 0;
-                       char *s = NULL;
+                       const char *s = NULL;
                        I32 old = 0;
 
                        if (pos_before >= data->last_start_min)
@@ -2364,14 +2350,14 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                            b = data->last_start_min;
 
                        l = 0;
-                       s = SvPV(data->last_found, l);
+                       s = SvPV_const(data->last_found, l);
                        old = b - data->last_start_min;
 
 #else
                        I32 b = pos_before >= data->last_start_min
                            ? pos_before : data->last_start_min;
                        STRLEN l;
-                       char *s = SvPV(data->last_found, l);
+                       const char *s = SvPV_const(data->last_found, l);
                        I32 old = b - data->last_start_min;
 #endif
 
@@ -2388,7 +2374,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
                            if (mincount > 1) {
                                SvGROW(last_str, (mincount * l) + 1);
                                repeatcpy(SvPVX(last_str) + l,
-                                         SvPVX(last_str), l, mincount - 1);
+                                         SvPVX_const(last_str), l, mincount - 1);
                                SvCUR_set(last_str, SvCUR(last_str) * mincount);
                                /* Add additional parts. */
                                SvCUR_set(data->last_found,
@@ -2703,7 +2689,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
            if (data)
                data->whilem_c = data_fake.whilem_c;
            if (f & SCF_DO_STCLASS_AND) {
-               int was = (data->start_class->flags & ANYOF_EOS);
+               const int was = (data->start_class->flags & ANYOF_EOS);
 
                cl_and(data->start_class, &intrnl);
                if (was)
@@ -2900,7 +2886,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
     r->prelen = xend - exp;
     r->precomp = savepvn(RExC_precomp, r->prelen);
     r->subbeg = NULL;
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
     r->saved_copy = Nullsv;
 #endif
     r->reganch = pm->op_pmflags & PMf_COMPILETIME;
@@ -3140,7 +3126,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
                      regprop(sv, (regnode*)data.start_class);
                      PerlIO_printf(Perl_debug_log,
                                    "synthetic stclass \"%s\".\n",
-                                   SvPVX(sv));});
+                                   SvPVX_const(sv));});
        }
 
        /* A temporary algorithm prefers floated substr to fixed one to dig more info. */
@@ -3195,7 +3181,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
                      regprop(sv, (regnode*)data.start_class);
                      PerlIO_printf(Perl_debug_log,
                                    "synthetic stclass \"%s\".\n",
-                                   SvPVX(sv));});
+                                   SvPVX_const(sv));});
        }
     }
 
@@ -3246,7 +3232,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
         wasted_c    = 0x04;
 
     char * parse_start = RExC_parse; /* MJD */
-    char *oregcomp_parse = RExC_parse;
+    char * const oregcomp_parse = RExC_parse;
     char c;
 
     *flagp = 0;                                /* Tentatively. */
@@ -3258,7 +3244,7 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
            U32 posflags = 0, negflags = 0;
            U32 *flagsp = &posflags;
            int logical = 0;
-           char *seqstart = RExC_parse;
+           const char * const seqstart = RExC_parse;
 
            RExC_parse++;
            paren = *RExC_parse++;
@@ -4474,7 +4460,6 @@ S_regwhite(pTHX_ char *p, const char *e)
 STATIC I32
 S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
 {
-    char *posixcc = 0;
     I32 namedclass = OOB_NAMEDCLASS;
 
     if (value == '[' && RExC_parse + 1 < RExC_end &&
@@ -4490,6 +4475,7 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
            RExC_parse = s;
        else {
            const char* t = RExC_parse++; /* skip over the c */
+           const char *posixcc;
 
            assert(*t == c);
 
@@ -5539,7 +5525,7 @@ S_reganode(pTHX_ RExC_state_t *pRExC_state, U8 op, U32 arg)
 - reguni - emit (if appropriate) a Unicode character
 */
 STATIC void
-S_reguni(pTHX_ RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
+S_reguni(pTHX_ const RExC_state_t *pRExC_state, UV uv, char* s, STRLEN* lenp)
 {
     *lenp = SIZE_ONLY ? UNISKIP(uv) : (uvchr_to_utf8((U8*)s, uv) - (U8*)s);
 }
@@ -5673,119 +5659,6 @@ S_regcurly(pTHX_ register const char *s)
 }
 
 
-#ifdef DEBUGGING
-
-STATIC regnode *
-S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l)
-{
-    register U8 op = EXACT;    /* Arbitrary non-END op. */
-    register regnode *next;
-
-    while (op != END && (!last || node < last)) {
-       /* While that wasn't END last time... */
-
-       NODE_ALIGN(node);
-       op = OP(node);
-       if (op == CLOSE)
-           l--;        
-       next = regnext(node);
-       /* Where, what. */
-       if (OP(node) == OPTIMIZED)
-           goto after_print;
-       regprop(sv, node);
-       PerlIO_printf(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start),
-                     (int)(2*l + 1), "", SvPVX(sv));
-       if (next == NULL)               /* Next ptr. */
-           PerlIO_printf(Perl_debug_log, "(0)");
-       else
-           PerlIO_printf(Perl_debug_log, "(%"IVdf")", (IV)(next - start));
-       (void)PerlIO_putc(Perl_debug_log, '\n');
-      after_print:
-       if (PL_regkind[(U8)op] == BRANCHJ) {
-           register regnode *nnode = (OP(next) == LONGJMP
-                                      ? regnext(next)
-                                      : next);
-           if (last && nnode > last)
-               nnode = last;
-           node = dumpuntil(start, NEXTOPER(NEXTOPER(node)), nnode, sv, l + 1);
-       }
-       else if (PL_regkind[(U8)op] == BRANCH) {
-           node = dumpuntil(start, NEXTOPER(node), next, sv, l + 1);
-       }
-       else if ( PL_regkind[(U8)op]  == TRIE ) {
-            const I32 n = ARG(node);
-            const reg_trie_data *trie = (reg_trie_data*)PL_regdata->data[n];
-            const I32 arry_len = av_len(trie->words)+1;
-           I32 word_idx;
-           PerlIO_printf(Perl_debug_log,
-                      "%*s[Words:%d Chars Stored:%d Unique Chars:%d States:%"IVdf"%s]\n",
-                      (int)(2*(l+3)),
-                      "",
-                      trie->wordcount,
-                      (int)trie->charcount,
-                      trie->uniquecharcount,
-                      (IV)trie->laststate-1,
-                      node->flags ? " EVAL mode" : "");
-
-           for (word_idx=0; word_idx < arry_len; word_idx++) {
-               SV **elem_ptr=av_fetch(trie->words,word_idx,0);
-               if (elem_ptr) {
-                   PerlIO_printf(Perl_debug_log, "%*s<%s%s%s>\n",
-                      (int)(2*(l+4)), "",
-                      PL_colors[0],
-                      SvPV_nolen(*elem_ptr),
-                      PL_colors[1]
-                   );
-                   /*
-                   if (next == NULL)
-                       PerlIO_printf(Perl_debug_log, "(0)\n");
-                   else
-                       PerlIO_printf(Perl_debug_log, "(%"IVdf")\n", (IV)(next - start));
-                   */
-               }
-
-           }
-
-           node = NEXTOPER(node);
-           node += regarglen[(U8)op];
-
-       }
-       else if ( op == CURLY) {   /* "next" might be very big: optimizer */
-           node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
-                            NEXTOPER(node) + EXTRA_STEP_2ARGS + 1, sv, l + 1);
-       }
-       else if (PL_regkind[(U8)op] == CURLY && op != CURLYX) {
-           node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
-                            next, sv, l + 1);
-       }
-       else if ( op == PLUS || op == STAR) {
-           node = dumpuntil(start, NEXTOPER(node), NEXTOPER(node) + 1, sv, l + 1);
-       }
-       else if (op == ANYOF) {
-           /* arglen 1 + class block */
-           node += 1 + ((ANYOF_FLAGS(node) & ANYOF_LARGE)
-                   ? ANYOF_CLASS_SKIP : ANYOF_SKIP);
-           node = NEXTOPER(node);
-       }
-       else if (PL_regkind[(U8)op] == EXACT) {
-            /* Literal string, where present. */
-           node += NODE_SZ_STR(node) - 1;
-           node = NEXTOPER(node);
-       }
-       else {
-           node = NEXTOPER(node);
-           node += regarglen[(U8)op];
-       }
-       if (op == CURLYX || op == OPEN)
-           l++;
-       else if (op == WHILEM)
-           l--;
-    }
-    return node;
-}
-
-#endif /* DEBUGGING */
-
 /*
  - regdump - dump a regexp onto Perl_debug_log in vaguely comprehensible form
  */
@@ -5803,7 +5676,7 @@ Perl_regdump(pTHX_ regexp *r)
                      "anchored \"%s%.*s%s\"%s at %"IVdf" ",
                      PL_colors[0],
                      (int)(SvCUR(r->anchored_substr) - (SvTAIL(r->anchored_substr)!=0)),
-                     SvPVX(r->anchored_substr),
+                     SvPVX_const(r->anchored_substr),
                      PL_colors[1],
                      SvTAIL(r->anchored_substr) ? "$" : "",
                      (IV)r->anchored_offset);
@@ -5812,7 +5685,7 @@ Perl_regdump(pTHX_ regexp *r)
                      "anchored utf8 \"%s%.*s%s\"%s at %"IVdf" ",
                      PL_colors[0],
                      (int)(SvCUR(r->anchored_utf8) - (SvTAIL(r->anchored_utf8)!=0)),
-                     SvPVX(r->anchored_utf8),
+                     SvPVX_const(r->anchored_utf8),
                      PL_colors[1],
                      SvTAIL(r->anchored_utf8) ? "$" : "",
                      (IV)r->anchored_offset);
@@ -5821,7 +5694,7 @@ Perl_regdump(pTHX_ regexp *r)
                      "floating \"%s%.*s%s\"%s at %"IVdf"..%"UVuf" ",
                      PL_colors[0],
                      (int)(SvCUR(r->float_substr) - (SvTAIL(r->float_substr)!=0)),
-                     SvPVX(r->float_substr),
+                     SvPVX_const(r->float_substr),
                      PL_colors[1],
                      SvTAIL(r->float_substr) ? "$" : "",
                      (IV)r->float_min_offset, (UV)r->float_max_offset);
@@ -5830,7 +5703,7 @@ Perl_regdump(pTHX_ regexp *r)
                      "floating utf8 \"%s%.*s%s\"%s at %"IVdf"..%"UVuf" ",
                      PL_colors[0],
                      (int)(SvCUR(r->float_utf8) - (SvTAIL(r->float_utf8)!=0)),
-                     SvPVX(r->float_utf8),
+                     SvPVX_const(r->float_utf8),
                      PL_colors[1],
                      SvTAIL(r->float_utf8) ? "$" : "",
                      (IV)r->float_min_offset, (UV)r->float_max_offset);
@@ -5848,7 +5721,7 @@ Perl_regdump(pTHX_ regexp *r)
 
     if (r->regstclass) {
        regprop(sv, r->regstclass);
-       PerlIO_printf(Perl_debug_log, "stclass \"%s\" ", SvPVX(sv));
+       PerlIO_printf(Perl_debug_log, "stclass \"%s\" ", SvPVX_const(sv));
     }
     if (r->reganch & ROPT_ANCH) {
        PerlIO_printf(Perl_debug_log, "anchored");
@@ -5887,22 +5760,6 @@ Perl_regdump(pTHX_ regexp *r)
 #endif /* DEBUGGING */
 }
 
-#ifdef DEBUGGING
-
-STATIC void
-S_put_byte(pTHX_ SV *sv, int c)
-{
-    if (isCNTRL(c) || c == 255 || !isPRINT(c))
-       Perl_sv_catpvf(aTHX_ sv, "\\%o", c);
-    else if (c == '-' || c == ']' || c == '\\' || c == '^')
-       Perl_sv_catpvf(aTHX_ sv, "\\%c", c);
-    else
-       Perl_sv_catpvf(aTHX_ sv, "%c", c);
-}
-
-#endif /* DEBUGGING */
-
-
 /*
 - regprop - printable representation of opcode
 */
@@ -6106,9 +5963,9 @@ Perl_re_intuit_string(pTHX_ regexp *prog)
 {                              /* Assume that RE_INTUIT is set */
     GET_RE_DEBUG_FLAGS_DECL;
     DEBUG_COMPILE_r(
-       {   STRLEN n_a;
-           const char *s = SvPV(prog->check_substr
-                     ? prog->check_substr : prog->check_utf8, n_a);
+       {
+           const char *s = SvPV_nolen_const(prog->check_substr
+                     ? prog->check_substr : prog->check_utf8);
 
            if (!PL_colorset) reginitcolors();
            PerlIO_printf(Perl_debug_log,
@@ -6156,7 +6013,7 @@ Perl_pregfree(pTHX_ struct regexp *r)
     if (r->offsets)             /* 20010421 MJD */
        Safefree(r->offsets);
     RX_MATCH_COPY_FREE(r);
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
     if (r->saved_copy)
        SvREFCNT_dec(r->saved_copy);
 #endif
@@ -6291,7 +6148,7 @@ S_re_croak2(pTHX_ const char* pat1,const char* pat2,...)
 #endif
     msv = vmess(buf, &args);
     va_end(args);
-    message = SvPV(msv,l1);
+    message = SvPV_const(msv,l1);
     if (l1 > 512)
        l1 = 512;
     Copy(message, buf, l1 , char);
@@ -6338,7 +6195,7 @@ Perl_save_re_context(pTHX)
     PL_reg_oldsaved = Nullch;
     SAVEI32(PL_reg_oldsavedlen);       /* old length of saved substr during match */
     PL_reg_oldsavedlen = 0;
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
     SAVESPTR(PL_nrs);
     PL_nrs = Nullsv;
 #endif
@@ -6381,6 +6238,131 @@ clear_re(pTHX_ void *r)
     ReREFCNT_dec((regexp *)r);
 }
 
+#ifdef DEBUGGING
+
+STATIC void
+S_put_byte(pTHX_ SV *sv, int c)
+{
+    if (isCNTRL(c) || c == 255 || !isPRINT(c))
+       Perl_sv_catpvf(aTHX_ sv, "\\%o", c);
+    else if (c == '-' || c == ']' || c == '\\' || c == '^')
+       Perl_sv_catpvf(aTHX_ sv, "\\%c", c);
+    else
+       Perl_sv_catpvf(aTHX_ sv, "%c", c);
+}
+
+
+STATIC regnode *
+S_dumpuntil(pTHX_ regnode *start, regnode *node, regnode *last, SV* sv, I32 l)
+{
+    register U8 op = EXACT;    /* Arbitrary non-END op. */
+    register regnode *next;
+
+    while (op != END && (!last || node < last)) {
+       /* While that wasn't END last time... */
+
+       NODE_ALIGN(node);
+       op = OP(node);
+       if (op == CLOSE)
+           l--;        
+       next = regnext(node);
+       /* Where, what. */
+       if (OP(node) == OPTIMIZED)
+           goto after_print;
+       regprop(sv, node);
+       PerlIO_printf(Perl_debug_log, "%4"IVdf":%*s%s", (IV)(node - start),
+                     (int)(2*l + 1), "", SvPVX_const(sv));
+       if (next == NULL)               /* Next ptr. */
+           PerlIO_printf(Perl_debug_log, "(0)");
+       else
+           PerlIO_printf(Perl_debug_log, "(%"IVdf")", (IV)(next - start));
+       (void)PerlIO_putc(Perl_debug_log, '\n');
+      after_print:
+       if (PL_regkind[(U8)op] == BRANCHJ) {
+           register regnode *nnode = (OP(next) == LONGJMP
+                                      ? regnext(next)
+                                      : next);
+           if (last && nnode > last)
+               nnode = last;
+           node = dumpuntil(start, NEXTOPER(NEXTOPER(node)), nnode, sv, l + 1);
+       }
+       else if (PL_regkind[(U8)op] == BRANCH) {
+           node = dumpuntil(start, NEXTOPER(node), next, sv, l + 1);
+       }
+       else if ( PL_regkind[(U8)op]  == TRIE ) {
+            const I32 n = ARG(node);
+           const reg_trie_data * const trie = (reg_trie_data*)PL_regdata->data[n];
+            const I32 arry_len = av_len(trie->words)+1;
+           I32 word_idx;
+           PerlIO_printf(Perl_debug_log,
+                      "%*s[Words:%d Chars Stored:%d Unique Chars:%d States:%"IVdf"%s]\n",
+                      (int)(2*(l+3)),
+                      "",
+                      trie->wordcount,
+                      (int)trie->charcount,
+                      trie->uniquecharcount,
+                      (IV)trie->laststate-1,
+                      node->flags ? " EVAL mode" : "");
+
+           for (word_idx=0; word_idx < arry_len; word_idx++) {
+               SV **elem_ptr=av_fetch(trie->words,word_idx,0);
+               if (elem_ptr) {
+                   PerlIO_printf(Perl_debug_log, "%*s<%s%s%s>\n",
+                      (int)(2*(l+4)), "",
+                      PL_colors[0],
+                      SvPV_nolen_const(*elem_ptr),
+                      PL_colors[1]
+                   );
+                   /*
+                   if (next == NULL)
+                       PerlIO_printf(Perl_debug_log, "(0)\n");
+                   else
+                       PerlIO_printf(Perl_debug_log, "(%"IVdf")\n", (IV)(next - start));
+                   */
+               }
+
+           }
+
+           node = NEXTOPER(node);
+           node += regarglen[(U8)op];
+
+       }
+       else if ( op == CURLY) {   /* "next" might be very big: optimizer */
+           node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
+                            NEXTOPER(node) + EXTRA_STEP_2ARGS + 1, sv, l + 1);
+       }
+       else if (PL_regkind[(U8)op] == CURLY && op != CURLYX) {
+           node = dumpuntil(start, NEXTOPER(node) + EXTRA_STEP_2ARGS,
+                            next, sv, l + 1);
+       }
+       else if ( op == PLUS || op == STAR) {
+           node = dumpuntil(start, NEXTOPER(node), NEXTOPER(node) + 1, sv, l + 1);
+       }
+       else if (op == ANYOF) {
+           /* arglen 1 + class block */
+           node += 1 + ((ANYOF_FLAGS(node) & ANYOF_LARGE)
+                   ? ANYOF_CLASS_SKIP : ANYOF_SKIP);
+           node = NEXTOPER(node);
+       }
+       else if (PL_regkind[(U8)op] == EXACT) {
+            /* Literal string, where present. */
+           node += NODE_SZ_STR(node) - 1;
+           node = NEXTOPER(node);
+       }
+       else {
+           node = NEXTOPER(node);
+           node += regarglen[(U8)op];
+       }
+       if (op == CURLYX || op == OPEN)
+           l++;
+       else if (op == WHILEM)
+           l--;
+    }
+    return node;
+}
+
+#endif /* DEBUGGING */
+
 /*
  * Local variables:
  * c-indentation-style: bsd