This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove repeated C<n_a>s
[perl5.git] / pp_ctl.c
index 8fd89c0..2cdb6ca 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -78,9 +78,7 @@ PP(pp_regcomp)
 {
     dSP;
     register PMOP *pm = (PMOP*)cLOGOP->op_other;
-    register char *t;
     SV *tmpstr;
-    STRLEN len;
     MAGIC *mg = Null(MAGIC*);
 
     /* prevent recompiling under /o and ithreads. */
@@ -129,7 +127,8 @@ PP(pp_regcomp)
        PM_SETRE(pm, ReREFCNT_inc(re));
     }
     else {
-       t = SvPV(tmpstr, len);
+       STRLEN len;
+       const char *t = SvPV_const(tmpstr, len);
 
        /* Check against the last compiled regexp. */
        if (!PM_GETRE(pm) || !PM_GETRE(pm)->precomp ||
@@ -151,7 +150,7 @@ PP(pp_regcomp)
                if (pm->op_pmdynflags & PMdf_UTF8)
                    t = (char*)bytes_to_utf8((U8*)t, &len);
            }
-           PM_SETRE(pm, CALLREGCOMP(aTHX_ t, t + len, pm));
+           PM_SETRE(pm, CALLREGCOMP(aTHX_ (char *)t, (char *)t + len, pm));
            if (!DO_UTF8(tmpstr) && (pm->op_pmdynflags & PMdf_UTF8))
                Safefree(t);
            PL_reginterp_cnt = 0;       /* XXXX Be extra paranoid - needed
@@ -234,7 +233,7 @@ PP(pp_substcont)
            }
            cx->sb_rxtainted |= RX_MATCH_TAINTED(rx);
 
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
            if (SvIsCOW(targ)) {
                sv_force_normal_flags(targ, SV_COW_DROP_PV);
            } else
@@ -309,7 +308,7 @@ Perl_rxres_save(pTHX_ void **rsp, REGEXP *rx)
     U32 i;
 
     if (!p || p[1] < rx->nparens) {
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
        i = 7 + rx->nparens * 2;
 #else
        i = 6 + rx->nparens * 2;
@@ -324,7 +323,7 @@ Perl_rxres_save(pTHX_ void **rsp, REGEXP *rx)
     *p++ = PTR2UV(RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch);
     RX_MATCH_COPIED_off(rx);
 
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
     *p++ = PTR2UV(rx->saved_copy);
     rx->saved_copy = Nullsv;
 #endif
@@ -349,7 +348,7 @@ Perl_rxres_restore(pTHX_ void **rsp, REGEXP *rx)
     RX_MATCH_COPIED_set(rx, *p);
     *p++ = 0;
 
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
     if (rx->saved_copy)
        SvREFCNT_dec (rx->saved_copy);
     rx->saved_copy = INT2PTR(SV*,*p);
@@ -373,7 +372,7 @@ Perl_rxres_free(pTHX_ void **rsp)
 
     if (p) {
        Safefree(INT2PTR(char*,*p));
-#ifdef PERL_COPY_ON_WRITE
+#ifdef PERL_OLD_COPY_ON_WRITE
        if (p[1]) {
            SvREFCNT_dec (INT2PTR(SV*,p[1]));
        }
@@ -389,7 +388,7 @@ PP(pp_formline)
     register SV *tmpForm = *++MARK;
     register U32 *fpc;
     register char *t;
-    register char *f;
+    const char *f;
     register char *s;
     register char *send;
     register I32 arg;
@@ -429,11 +428,9 @@ PP(pp_formline)
        targ_is_utf8 = TRUE;
     t = SvGROW(PL_formtarget, len + fudge + 1);  /* XXX SvCUR bad */
     t += len;
-    f = SvPV(tmpForm, len);
+    f = SvPV_const(tmpForm, len);
     /* need to jump to the next word */
-    s = f + len + WORD_ALIGN - SvCUR(tmpForm) % WORD_ALIGN;
-
-    fpc = (U32*)s;
+    fpc = (U32*)(f + len + WORD_ALIGN - SvCUR(tmpForm) % WORD_ALIGN);
 
     for (;;) {
        DEBUG_f( {
@@ -512,7 +509,7 @@ PP(pp_formline)
            break;
 
        case FF_CHECKNL:
-           item = s = SvPV(sv, len);
+           s = item = SvPV(sv, len);
            itemsize = len;
            if (DO_UTF8(sv)) {
                itemsize = sv_len_utf8(sv);
@@ -554,7 +551,7 @@ PP(pp_formline)
            break;
 
        case FF_CHECKCHOP:
-           item = s = SvPV(sv, len);
+           s = item = SvPV(sv, len);
            itemsize = len;
            if (DO_UTF8(sv)) {
                itemsize = sv_len_utf8(sv);
@@ -733,7 +730,7 @@ PP(pp_formline)
        case FF_LINEGLOB:
            oneline = FALSE;
        ff_line:
-           item = s = SvPV(sv, len);
+           s = item = SvPV(sv, len);
            itemsize = len;
            if ((item_is_utf8 = DO_UTF8(sv)))
                itemsize = sv_len_utf8(sv);
@@ -1137,11 +1134,11 @@ PP(pp_flop)
        }
        else {
            SV *final = sv_mortalcopy(right);
-           STRLEN len, n_a;
+           STRLEN len;
            const char *tmps = SvPV(final, len);
 
            sv = sv_mortalcopy(left);
-           SvPV_force(sv,n_a);
+           SvPV_force_nolen(sv);
            while (!SvNIOKp(sv) && SvCUR(sv) <= len) {
                XPUSHs(sv);
                if (strEQ(SvPVX_const(sv),tmps))
@@ -1384,7 +1381,6 @@ OP *
 Perl_die_where(pTHX_ const char *message, STRLEN msglen)
 {
     dVAR;
-    STRLEN n_a;
 
     if (PL_in_eval) {
        I32 cxix;
@@ -1399,8 +1395,9 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
                if (!SvPOK(err))
                    sv_setpvn(err,"",0);
                else if (SvCUR(err) >= sizeof(prefix)+msglen-1) {
-                   e = SvPV(err, n_a);
-                   e += n_a - msglen;
+                   STRLEN len;
+                   e = SvPV(err, len);
+                   e += len - msglen;
                    if (*e != *message || strNE(e,message))
                        e = Nullch;
                }
@@ -1456,7 +1453,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
            PL_curcop = cx->blk_oldcop;
 
            if (optype == OP_REQUIRE) {
-                const char* msg = SvPVx(ERRSV, n_a);
+                const char* msg = SvPVx_nolen_const(ERRSV);
                 SV *nsv = cx->blk_eval.old_namesv;
                 (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv),
                                &PL_sv_undef, 0);
@@ -1653,8 +1650,8 @@ PP(pp_caller)
     if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.hasargs
        && CopSTASH_eq(PL_curcop, PL_debstash))
     {
-       AV *ary = cx->blk_sub.argarray;
-        const int off = AvARRAY(ary) - AvALLOC(ary);
+       AV * const ary = cx->blk_sub.argarray;
+       const int off = AvARRAY(ary) - AvALLOC(ary);
 
        if (!PL_dbargs) {
            GV* tmpgv;
@@ -1705,12 +1702,11 @@ PP(pp_reset)
 {
     dSP;
     const char *tmps;
-    STRLEN n_a;
 
     if (MAXARG < 1)
        tmps = "";
     else
-       tmps = POPpx;
+       tmps = POPpconstx;
     sv_reset(tmps, CopSTASH(PL_curcop));
     PUSHs(&PL_sv_yes);
     RETURN;
@@ -1835,10 +1831,9 @@ PP(pp_enteriter)
                cx->blk_loop.itermax = SvIV(right);
            }
            else {
-               STRLEN n_a;
                cx->blk_loop.iterlval = newSVsv(sv);
-               (void) SvPV_force(cx->blk_loop.iterlval,n_a);
-               (void) SvPV(right,n_a);
+               (void) SvPV_force_nolen(cx->blk_loop.iterlval);
+               (void) SvPV_nolen_const(right);
            }
        }
        else if (PL_op->op_private & OPpITER_REVERSED) {
@@ -2256,7 +2251,6 @@ PP(pp_goto)
 
     if (PL_op->op_flags & OPf_STACKED) {
        SV *sv = POPs;
-       STRLEN n_a;
 
        /* This egregious kludge implements goto &subroutine */
        if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVCV) {
@@ -2466,7 +2460,7 @@ PP(pp_goto)
            }
        }
        else {
-           label = SvPV(sv,n_a);
+           label = SvPV_nolen_const(sv);
            if (!(do_dump || *label))
                DIE(aTHX_ must_have_label);
        }
@@ -2645,8 +2639,7 @@ PP(pp_cswitch)
     if (PL_multiline)
        PL_op = PL_op->op_next;                 /* can't assume anything */
     else {
-       STRLEN n_a;
-       match = *(SvPVx(GvSV(cCOP->cop_gv), n_a)) & 255;
+       match = *(SvPVx_nolen_const(GvSV(cCOP->cop_gv))) & 255;
        match -= cCOP->uop.scop.scop_offset;
        if (match < 0)
            match = 0;
@@ -2930,7 +2923,6 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
        SV **newsp;                     /* Used by POPBLOCK. */
        PERL_CONTEXT *cx = &cxstack[cxstack_ix];
        I32 optype = 0;                 /* Might be reset by POPEVAL. */
-       STRLEN n_a;
 
        PL_op = saveop;
        if (PL_eval_root) {
@@ -2945,7 +2937,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
        lex_end();
        LEAVE;
        if (optype == OP_REQUIRE) {
-           const char* const msg = SvPVx(ERRSV, n_a);
+           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);
@@ -2953,7 +2945,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
                *msg ? msg : "Unknown error\n");
        }
        else if (startop) {
-            const char* msg = SvPVx(ERRSV, n_a);
+            const char* msg = SvPVx_nolen_const(ERRSV);
 
            POPBLOCK(cx,PL_curpm);
            POPEVAL(cx);
@@ -2961,7 +2953,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
                       (*msg ? msg : "Unknown error\n"));
        }
        else {
-            const char* msg = SvPVx(ERRSV, n_a);
+            const char* msg = SvPVx_nolen_const(ERRSV);
            if (!*msg) {
                sv_setpv(ERRSV, "Compilation error");
            }
@@ -3054,9 +3046,9 @@ PP(pp_require)
     dVAR; dSP;
     register PERL_CONTEXT *cx;
     SV *sv;
-    char *name;
+    const char *name;
     STRLEN len;
-    char *tryname = Nullch;
+    const char *tryname = Nullch;
     SV *namesv = Nullsv;
     SV** svp;
     const I32 gimme = GIMME_V;
@@ -3084,7 +3076,7 @@ PP(pp_require)
 
            RETPUSHYES;
     }
-    name = SvPV(sv, len);
+    name = SvPV_const(sv, len);
     if (!(name && len > 0 && *name))
        DIE(aTHX_ "Null filename used");
     TAINT_PROPER("require");
@@ -3245,8 +3237,7 @@ PP(pp_require)
                        || (*name == ':' && name[1] != ':' && strchr(name+2, ':'))
 #endif
                  ) {
-                   STRLEN n_a;
-                   char *dir = SvPVx(dirsv, n_a);
+                   const char *dir = SvPVx_nolen_const(dirsv);
 #ifdef MACOS_TRADITIONAL
                    char buf1[256];
                    char buf2[256];
@@ -3296,7 +3287,7 @@ PP(pp_require)
     SvREFCNT_dec(namesv);
     if (!tryrsfp) {
        if (PL_op->op_type == OP_REQUIRE) {
-           char *msgstr = name;
+           const char *msgstr = name;
            if (namesv) {                       /* did we lookup @INC? */
                SV *msg = sv_2mortal(newSVpv(msgstr,0));
                SV *dirmsgsv = NEWSV(0, 0);
@@ -3309,8 +3300,7 @@ PP(pp_require)
                    sv_catpv(msg, " (did you run h2ph?)");
                sv_catpv(msg, " (@INC contains:");
                for (i = 0; i <= AvFILL(ar); i++) {
-                   STRLEN n_a;
-                   const char *dir = SvPVx(*av_fetch(ar, i, TRUE), n_a);
+                   const char *dir = SvPVx_nolen_const(*av_fetch(ar, i, TRUE));
                    Perl_sv_setpvf(aTHX_ dirmsgsv, " %s", dir);
                    sv_catsv(msg, dirmsgsv);
                }
@@ -3406,7 +3396,7 @@ PP(pp_entereval)
     CV* runcv;
     U32 seq;
 
-    if (!SvPV(sv,len))
+    if (!SvPV_const(sv,len))
        RETPUSHUNDEF;
     TAINT_PROPER("eval");