more embed cleanup
[p5sagit/p5-mst-13.2.git] / pp_ctl.c
index e27d637..2a10ab0 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -204,7 +204,7 @@ PP(pp_substcont)
     }
 
     rxres_restore(&cx->sb_rxres, rx);
-    RX_MATCH_UTF8_set(rx, SvUTF8(cx->sb_targ));
+    RX_MATCH_UTF8_set(rx, DO_UTF8(cx->sb_targ));
 
     if (cx->sb_iters++) {
        const I32 saviters = cx->sb_iters;
@@ -314,7 +314,7 @@ Perl_rxres_save(pTHX_ void **rsp, REGEXP *rx)
        i = 6 + rx->nparens * 2;
 #endif
        if (!p)
-           New(501, p, i, UV);
+           Newx(p, i, UV);
        else
            Renew(p, i, UV);
        *rsp = (void*)p;
@@ -371,7 +371,14 @@ Perl_rxres_free(pTHX_ void **rsp)
     UV *p = (UV*)*rsp;
 
     if (p) {
+#ifdef PERL_POISON
+       void *tmp = INT2PTR(char*,*p);
+       Safefree(tmp);
+       if (*p)
+           Poison(*p, 1, sizeof(*p));
+#else
        Safefree(INT2PTR(char*,*p));
+#endif
 #ifdef PERL_OLD_COPY_ON_WRITE
        if (p[1]) {
            SvREFCNT_dec (INT2PTR(SV*,p[1]));
@@ -1771,7 +1778,8 @@ PP(pp_dbstate)
        PUSHSUB_DB(cx);
        cx->blk_sub.retop = PL_op->op_next;
        CvDEPTH(cv)++;
-       PAD_SET_CUR(CvPADLIST(cv),1);
+       SAVECOMPPAD();
+       PAD_SET_CUR_NOSAVE(CvPADLIST(cv), 1);
        RETURNOP(CvSTART(cv));
     }
     else
@@ -2055,6 +2063,7 @@ PP(pp_last)
     SV **mark;
     SV *sv = Nullsv;
 
+
     if (PL_op->op_flags & OPf_SPECIAL) {
        cxix = dopoptoloop(cxstack_ix);
        if (cxix < 0)
@@ -2069,7 +2078,6 @@ PP(pp_last)
        dounwind(cxix);
 
     POPBLOCK(cx,newpm);
-    PERL_UNUSED_VAR(optype);
     cxstack_ix++; /* temporarily protect top context */
     mark = newsp;
     switch (CxTYPE(cx)) {
@@ -2127,6 +2135,8 @@ PP(pp_last)
     PL_curpm = newpm;  /* ... and pop $1 et al */
 
     LEAVESUB(sv);
+    PERL_UNUSED_VAR(optype);
+    PERL_UNUSED_VAR(gimme);
     return nextop;
 }
 
@@ -2200,7 +2210,6 @@ PP(pp_redo)
 STATIC OP *
 S_dofindlabel(pTHX_ OP *o, const char *label, OP **opstack, OP **oplimit)
 {
-    OP *kid = Nullop;
     OP **ops = opstack;
     static const char too_deep[] = "Target of goto is too deeply nested";
 
@@ -2218,6 +2227,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, OP **opstack, OP **oplimit)
     }
     *ops = 0;
     if (o->op_flags & OPf_KIDS) {
+       OP *kid;
        /* First try all the kids at this level, since that's likeliest. */
        for (kid = cUNOPo->op_first; kid; kid = kid->op_sibling) {
            if ((kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) &&
@@ -2263,7 +2273,7 @@ PP(pp_goto)
     static const char must_have_label[] = "goto must have label";
 
     if (PL_op->op_flags & OPf_STACKED) {
-       SV *sv = POPs;
+       SV * const sv = POPs;
 
        /* This egregious kludge implements goto &subroutine */
        if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV) {
@@ -2333,8 +2343,7 @@ PP(pp_goto)
                }
            }
            else if (CvXSUB(cv)) {      /* put GvAV(defgv) back onto stack */
-               AV* av;
-               av = GvAV(PL_defgv);
+               AV* const av = GvAV(PL_defgv);
                items = AvFILLp(av) + 1;
                EXTEND(SP, items+1); /* @_ could have been extended. */
                Copy(AvARRAY(av), SP + 1, items, SV*);
@@ -2408,7 +2417,8 @@ PP(pp_goto)
                        sub_crush_depth(cv);
                    pad_push(padlist, CvDEPTH(cv));
                }
-               PAD_SET_CUR(padlist, CvDEPTH(cv));
+               SAVECOMPPAD();
+               PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
                if (cx->blk_sub.hasargs)
                {
                    AV* av = (AV*)PAD_SVl(0);
@@ -2452,12 +2462,12 @@ PP(pp_goto)
                     * We do not care about using sv to call CV;
                     * it's for informational purposes only.
                     */
-                   SV *sv = GvSV(PL_DBsub);
+                   SV * const sv = GvSV(PL_DBsub);
                    CV *gotocv;
 
                    save_item(sv);
                    if (PERLDB_SUB_NN) {
-                       int type = SvTYPE(sv);
+                       const int type = SvTYPE(sv);
                        if (type < SVt_PVIV && type != SVt_IV)
                            sv_upgrade(sv, SVt_PVIV);
                        (void)SvIOK_on(sv);
@@ -2673,12 +2683,12 @@ STATIC void
 S_save_lines(pTHX_ AV *array, SV *sv)
 {
     const char *s = SvPVX_const(sv);
-    const char *send = SvPVX_const(sv) + SvCUR(sv);
+    const char * const send = SvPVX_const(sv) + SvCUR(sv);
     I32 line = 1;
 
     while (s && s < send) {
        const char *t;
-       SV *tmpstr = NEWSV(85,0);
+       SV * const tmpstr = NEWSV(85,0);
 
        sv_upgrade(tmpstr, SVt_PVMG);
        t = strchr(s, '\n');
@@ -2759,7 +2769,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
     dVAR; dSP;                         /* Make POPBLOCK work. */
     PERL_CONTEXT *cx;
     SV **newsp;
-    I32 gimme = 0;   /* SUSPECT - INITIALZE TO WHAT?  NI-S */
+    I32 gimme = G_VOID;
     I32 optype;
     OP dummy;
     OP *rop;
@@ -2779,7 +2789,7 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
        CopSTASH_set(&PL_compiling, PL_curstash);
     }
     if (PERLDB_NAMEEVAL && CopLINE(PL_curcop)) {
-       SV *sv = sv_newmortal();
+       SV * const sv = sv_newmortal();
        Perl_sv_setpvf(aTHX_ sv, "_<(%.10seval %lu)[%s:%"IVdf"]",
                       code, (unsigned long)++PL_evalseq,
                       CopFILE(PL_curcop), (IV)CopLINE(PL_curcop));
@@ -2834,6 +2844,9 @@ Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
 #ifdef OP_IN_REGISTER
     op = PL_opsave;
 #endif
+    PERL_UNUSED_VAR(newsp);
+    PERL_UNUSED_VAR(optype);
+
     return rop;
 }
 
@@ -2889,7 +2902,7 @@ STATIC OP *
 S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
 {
     dVAR; dSP;
-    OP *saveop = PL_op;
+    OP * const saveop = PL_op;
 
     PL_in_eval = ((saveop && saveop->op_type == OP_REQUIRE)
                  ? (EVAL_INREQUIRE | (PL_in_eval & EVAL_INEVAL))
@@ -2937,8 +2950,9 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
        sv_setpvn(ERRSV,"",0);
     if (yyparse() || PL_error_count || !PL_eval_root) {
        SV **newsp;                     /* Used by POPBLOCK. */
-       PERL_CONTEXT *cx = &cxstack[cxstack_ix];
+       PERL_CONTEXT *cx = &cxstack[cxstack_ix];
        I32 optype = 0;                 /* Might be reset by POPEVAL. */
+       const char *msg;
 
        PL_op = saveop;
        if (PL_eval_root) {
@@ -2952,8 +2966,9 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
        }
        lex_end();
        LEAVE;
+
+       msg = SvPVx_nolen_const(ERRSV);
        if (optype == OP_REQUIRE) {
-           const char* const msg = SvPVx_nolen_const(ERRSV);
            const SV * const nsv = cx->blk_eval.old_namesv;
            (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
                           &PL_sv_undef, 0);
@@ -2961,19 +2976,17 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
                *msg ? msg : "Unknown error\n");
        }
        else if (startop) {
-            const char* msg = SvPVx_nolen_const(ERRSV);
-
            POPBLOCK(cx,PL_curpm);
            POPEVAL(cx);
            Perl_croak(aTHX_ "%sCompilation failed in regexp",
                       (*msg ? msg : "Unknown error\n"));
        }
        else {
-            const char* msg = SvPVx_nolen_const(ERRSV);
            if (!*msg) {
                sv_setpv(ERRSV, "Compilation error");
            }
        }
+       PERL_UNUSED_VAR(newsp);
        RETPUSHUNDEF;
     }
     CopLINE_set(&PL_compiling, 0);
@@ -3001,7 +3014,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
 
     /* Register with debugger: */
     if (PERLDB_INTER && saveop->op_type == OP_REQUIRE) {
-       CV *cv = get_cv("DB::postponed", FALSE);
+       CV * const cv = get_cv("DB::postponed", FALSE);
        if (cv) {
            dSP;
            PUSHMARK(SP);
@@ -3029,14 +3042,14 @@ S_doopen_pm(pTHX_ const char *name, const char *mode)
     PerlIO *fp;
 
     if (namelen > 3 && strEQ(name + namelen - 3, ".pm")) {
-       SV *pmcsv = Perl_newSVpvf(aTHX_ "%s%c", name, 'c');
+       SV * const pmcsv = Perl_newSVpvf(aTHX_ "%s%c", name, 'c');
        const char * const pmc = SvPV_nolen_const(pmcsv);
-       Stat_t pmstat;
        Stat_t pmcstat;
        if (PerlLIO_stat(pmc, &pmcstat) < 0) {
            fp = PerlIO_open(name, mode);
        }
        else {
+           Stat_t pmstat;
            if (PerlLIO_stat(name, &pmstat) < 0 ||
                pmstat.st_mtime < pmcstat.st_mtime)
            {
@@ -3364,7 +3377,7 @@ PP(pp_require)
     PL_compiling.cop_io = Nullsv;
 
     if (filter_sub || filter_child_proc) {
-       SV *datasv = filter_add(run_user_filter, Nullsv);
+       SV * const datasv = filter_add(run_user_filter, Nullsv);
        IoLINES(datasv) = filter_has_file;
        IoFMT_GV(datasv) = (GV *)filter_child_proc;
        IoTOP_GV(datasv) = (GV *)filter_state;
@@ -3403,7 +3416,8 @@ PP(pp_entereval)
     dVAR; dSP;
     register PERL_CONTEXT *cx;
     dPOPss;
-    const I32 gimme = GIMME_V, was = PL_sub_generation;
+    const I32 gimme = GIMME_V;
+    const I32 was = PL_sub_generation;
     char tbuf[TYPE_DIGITS(long) + 12];
     char *tmpbuf = tbuf;
     char *safestr;
@@ -3423,7 +3437,7 @@ PP(pp_entereval)
     /* switch to eval mode */
 
     if (PERLDB_NAMEEVAL && CopLINE(PL_curcop)) {
-       SV *sv = sv_newmortal();
+       SV * const sv = sv_newmortal();
        Perl_sv_setpvf(aTHX_ sv, "_<(eval %lu)[%s:%"IVdf"]",
                       (unsigned long)++PL_evalseq,
                       CopFILE(PL_curcop), (IV)CopLINE(PL_curcop));
@@ -3581,6 +3595,7 @@ PP(pp_leavetry)
 
     POPBLOCK(cx,newpm);
     POPEVAL(cx);
+    PERL_UNUSED_VAR(optype);
 
     TAINT_NOT;
     if (gimme == G_VOID)
@@ -3645,7 +3660,7 @@ S_doparseform(pTHX_ SV *sv)
     s = base;
     base = Nullch;
 
-    New(804, fops, maxops, U32);
+    Newx(fops, maxops, U32);
     fpc = fops;
 
     if (s < send) {