Upgrade to Text-Tabs+Wrap-2006.0711. Keep the local changes from
[p5sagit/p5-mst-13.2.git] / regcomp.c
index 6165317..10c6682 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -1053,6 +1053,10 @@ S_make_trie_failtable(pTHX_ RExC_state_t *pRExC_state, regnode *source,  regnode
     reg_ac_data *aho;
     const U32 data_slot = add_data( pRExC_state, 1, "T" );
     GET_RE_DEBUG_FLAGS_DECL;
+#ifndef DEBUGGING
+    PERL_UNUSED_ARG(depth);
+#endif    
+
 
     ARG_SET( stclass, data_slot );
     Newxz( aho, 1, reg_ac_data );
@@ -1062,7 +1066,8 @@ S_make_trie_failtable(pTHX_ RExC_state_t *pRExC_state, regnode *source,  regnode
         (trie->laststate+1)*sizeof(reg_trie_state));
     Newxz( q, numstates, U32);
     Newxz( aho->fail, numstates, U32 );
-    fail= aho->fail;
+    aho->refcount = 1;
+    fail = aho->fail;
     fail[ 0 ] = fail[ 1 ] = 1;
 
     for ( charid = 0; charid < ucharcount ; charid++ ) {
@@ -1148,6 +1153,9 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
     AV *trie_revcharmap;
 #endif
     GET_RE_DEBUG_FLAGS_DECL;
+#ifndef DEBUGGING
+    PERL_UNUSED_ARG(depth);
+#endif
 
     Newxz( trie, 1, reg_trie_data );
     trie->refcount = 1;
@@ -1768,8 +1776,10 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs
                     STR_LEN(convert)++;
 
                } else {
+#ifdef DEBUGGING           
                    if (state>1)
                        DEBUG_OPTIMISE_r(PerlIO_printf( Perl_debug_log,"]\n"));
+#endif
                    break;
                }
            }
@@ -1866,8 +1876,14 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags
     U32 stopnow = 0;
 #ifdef DEBUGGING
     regnode *stop = scan;
-#endif
     GET_RE_DEBUG_FLAGS_DECL;
+#else
+    PERL_UNUSED_ARG(depth);
+#endif
+#ifndef EXPERIMENTAL_INPLACESCAN
+    PERL_UNUSED_ARG(flags);
+    PERL_UNUSED_ARG(val);
+#endif
     DEBUG_PEEP("join",scan,depth);
     
     /* Skip NOTHING, merge EXACT*. */
@@ -1880,7 +1896,6 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags
         if (OP(n) == TAIL || n > next)
             stringok = 0;
         if (PL_regkind[OP(n)] == NOTHING) {
-        
             DEBUG_PEEP("skip:",n,depth);
             NEXT_OFF(scan) += NEXT_OFF(n);
             next = n + NODE_STEP_REGNODE;
@@ -1911,17 +1926,17 @@ S_join_exact(pTHX_ RExC_state_t *pRExC_state, regnode *scan, I32 *min, U32 flags
             if (stopnow) break;
         }
 
-#ifdef  EXPERIMENTAL_INPLACESCAN
-        if (flags && !NEXT_OFF(n)) {
-            DEBUG_PEEP("atch",val,depth);            
-            if (reg_off_by_arg[OP(n)]) {
-               ARG_SET(n, val - n);
-            }
-            else {
-               NEXT_OFF(n) = val - n;
-            }
-            stopnow=1;
-        }            
+#ifdef EXPERIMENTAL_INPLACESCAN
+       if (flags && !NEXT_OFF(n)) {
+           DEBUG_PEEP("atch", val, depth);
+           if (reg_off_by_arg[OP(n)]) {
+               ARG_SET(n, val - n);
+           }
+           else {
+               NEXT_OFF(n) = val - n;
+           }
+           stopnow = 1;
+       }
 #endif
     }
     
@@ -2011,6 +2026,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap,
     SV *re_trie_maxbuff = NULL;
 
     GET_RE_DEBUG_FLAGS_DECL;
+#ifdef DEBUGGING
+    StructCopy(&zero_scan_data, &data_fake, scan_data_t);    
+#endif
 
     while (scan && OP(scan) != END && scan < last) {
        /* Peephole optimizer: */
@@ -3371,7 +3389,7 @@ reStudy:
                if (OP(first) == IFMATCH) {
                    first = NEXTOPER(first);
                    first += EXTRA_STEP_2ARGS;
-               } else  /*xxx possible optimisation for /(?=)/*/
+               } else  /* XXX possible optimisation for /(?=)/  */
                    first = NEXTOPER(first);
        }
 
@@ -3656,6 +3674,18 @@ reStudy:
         PerlIO_printf(Perl_debug_log,"Final program:\n");
         regdump(r);
     });
+    DEBUG_OFFSETS_r(if (r->offsets) {
+        const U32 len = r->offsets[0];
+        U32 i;
+        GET_RE_DEBUG_FLAGS_DECL;
+        PerlIO_printf(Perl_debug_log, "Offsets: [%"UVuf"]\n\t", (UV)r->offsets[0]);
+        for (i = 1; i <= len; i++) {
+            if (r->offsets[i*2-1] || r->offsets[i*2])
+                PerlIO_printf(Perl_debug_log, "%"UVuf":%"UVuf"[%"UVuf"] ",
+                i, (UV)r->offsets[i*2-1], (UV)r->offsets[i*2]);
+            }
+        PerlIO_printf(Perl_debug_log, "\n");
+    });
     return(r);
 }
 
@@ -5157,6 +5187,10 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state, U32 depth)
         case we need to change the emitted regop to an EXACT. */
     const char * orig_parse = RExC_parse;
     GET_RE_DEBUG_FLAGS_DECL;
+#ifndef DEBUGGING
+    PERL_UNUSED_ARG(depth);
+#endif
+
     DEBUG_PARSE("clas");
 
     /* Assume we are going to generate an ANYOF node. */
@@ -6126,6 +6160,9 @@ S_regtail(pTHX_ RExC_state_t *pRExC_state, regnode *p, const regnode *val,U32 de
     dVAR;
     register regnode *scan;
     GET_RE_DEBUG_FLAGS_DECL;
+#ifndef DEBUGGING
+    PERL_UNUSED_ARG(depth);
+#endif
 
     if (SIZE_ONLY)
        return;
@@ -6355,19 +6392,6 @@ Perl_regdump(pTHX_ const regexp *r)
     if (r->reganch & ROPT_EVAL_SEEN)
        PerlIO_printf(Perl_debug_log, "with eval ");
     PerlIO_printf(Perl_debug_log, "\n");
-    if (r->offsets) {
-        const U32 len = r->offsets[0];
-        GET_RE_DEBUG_FLAGS_DECL;
-        DEBUG_OFFSETS_r({
-           U32 i;
-           PerlIO_printf(Perl_debug_log, "Offsets: [%"UVuf"]\n\t", (UV)r->offsets[0]);
-           for (i = 1; i <= len; i++) {
-               PerlIO_printf(Perl_debug_log, "%"UVuf":%"UVuf"[%"UVuf"] ",
-                   i, (UV)r->offsets[i*2-1], (UV)r->offsets[i*2]);
-            }
-           PerlIO_printf(Perl_debug_log, "\n");
-        });
-    }
 #else
     PERL_UNUSED_CONTEXT;
     PERL_UNUSED_ARG(r);
@@ -6399,13 +6423,8 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
         * be the best for now since we have no flag "this EXACTish
         * node was UTF-8" --jhi */
        const bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
-       const char * const s = do_utf8 ?
-         pv_uni_display(dsv, (U8*)STRING(o), STR_LEN(o), 60,
-                        UNI_DISPLAY_REGEX) :
-         STRING(o);
-       const int len = do_utf8 ?
-         strlen(s) :
-         STR_LEN(o);
+       RE_PV_DISPLAY_DECL(s, len, do_utf8, dsv, STRING(o), STR_LEN(o), 60);
+
        Perl_sv_catpvf(aTHX_ sv, " <%s%.*s%s>",
                       PL_colors[0],
                       len, s,
@@ -6570,6 +6589,7 @@ Perl_regprop(pTHX_ const regexp *prog, SV *sv, const regnode *o)
     PERL_UNUSED_CONTEXT;
     PERL_UNUSED_ARG(sv);
     PERL_UNUSED_ARG(o);
+    PERL_UNUSED_ARG(prog);
 #endif /* DEBUGGING */
 }
 
@@ -6603,26 +6623,25 @@ void
 Perl_pregfree(pTHX_ struct regexp *r)
 {
     dVAR;
-#ifdef DEBUGGING
-    SV * const dsv = PERL_DEBUG_PAD_ZERO(0);
-#endif
+
+
+
     GET_RE_DEBUG_FLAGS_DECL;
 
     if (!r || (--r->refcnt > 0))
        return;
     DEBUG_COMPILE_r(if (RX_DEBUG(r)){
-        const char * const s = (r->reganch & ROPT_UTF8)
-            ? pv_uni_display(dsv, (U8*)r->precomp, r->prelen, 60, UNI_DISPLAY_REGEX)
-            : pv_display(dsv, r->precomp, r->prelen, 0, 60);
-        const int len = SvCUR(dsv);
-        if (!PL_colorset)
-             reginitcolors();
-        PerlIO_printf(Perl_debug_log,
-                      "%sFreeing REx:%s %s%*.*s%s%s\n",
-                      PL_colors[4],PL_colors[5],PL_colors[0],
-                      len, len, s,
-                      PL_colors[1],
-                      len > 60 ? "..." : "");
+       RE_PV_DISPLAY_DECL(s, len, (r->reganch & ROPT_UTF8),
+           PERL_DEBUG_PAD_ZERO(0), r->precomp, r->prelen, 60);
+
+       if (!PL_colorset)
+           reginitcolors();
+       PerlIO_printf(Perl_debug_log,
+           "%sFreeing REx:%s %s%*.*s%s%s\n",
+           PL_colors[4],PL_colors[5],PL_colors[0],
+           len, len, s,
+           PL_colors[1],
+           len > 60 ? "..." : "");
     });
 
     /* gcov results gave these as non-null 100% of the time, so there's no
@@ -6899,7 +6918,7 @@ S_dumpuntil(pTHX_ const regexp *r, const regnode *start, const regnode *node,
        
        /* Where, what. */
        if (OP(node) == OPTIMIZED) {
-           if (!optstart && (SvIV(re_debug_flags) & RE_DEBUG_COMPILE_OPTIMISE))
+           if (!optstart && RE_DEBUG_FLAG(RE_DEBUG_COMPILE_OPTIMISE))
                optstart = node;
            else
                goto after_print;