Propagate const/mutable/not into the SvPV call for retrieving an
[p5sagit/p5-mst-13.2.git] / scope.c
diff --git a/scope.c b/scope.c
index 8b3821e..31a3ebc 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -67,7 +67,7 @@ Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
 I32
 Perl_cxinc(pTHX)
 {
-    IV old_max = cxstack_max;
+    const IV old_max = cxstack_max;
     cxstack_max = GROW(cxstack_max);
     Renew(cxstack, cxstack_max + 1, PERL_CONTEXT);     /* XXX should fix CXINC macro */
     /* Without any kind of initialising deep enough recursion
@@ -267,7 +267,7 @@ Perl_save_gp(pTHX_ GV *gv, I32 empty)
     SSPUSHIV((IV)SvLEN(gv));
     SvLEN_set(gv, 0); /* forget that anything was allocated here */
     SSPUSHIV((IV)SvCUR(gv));
-    SSPUSHPTR(SvPVX(gv));
+    SSPUSHPTR(SvPVX_const(gv));
     SvPOK_off(gv);
     SSPUSHPTR(SvREFCNT_inc(gv));
     SSPUSHPTR(GvGP(gv));
@@ -469,11 +469,7 @@ Perl_save_threadsv(pTHX_ PADOFFSET i)
 {
     Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
     (void)i;
-#ifndef HASATTRIBUTE
-    /* No __attribute__, so the compiler doesn't know that croak never returns
-     */
-    return 0;
-#endif
+    NORETURN_FUNCTION_END;
 }
 
 void
@@ -724,7 +720,7 @@ Perl_leave_scope(pTHX_ I32 base)
            if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
                SvTYPE(sv) != SVt_PVGV)
            {
-               (void)SvUPGRADE(value, SvTYPE(sv));
+               SvUPGRADE(value, SvTYPE(sv));
                SvMAGIC_set(value, SvMAGIC(sv));
                SvFLAGS(value) |= SvMAGICAL(sv);
                SvMAGICAL_off(sv);
@@ -759,6 +755,9 @@ Perl_leave_scope(pTHX_ I32 base)
            gv = (GV*)SSPOPPTR;
            if (GvAV(gv)) {
                AV * const goner = GvAV(gv);
+               /* FIXME - this is a temporary hack until we work out what
+                  the correct behaviour for magic should be.  */
+               sv_unmagic((SV*)goner, PERL_MAGIC_arylen_p);
                SvMAGIC_set(av, SvMAGIC(goner));
                SvFLAGS((SV*)av) |= SvMAGICAL(goner);
                SvMAGICAL_off(goner);
@@ -842,8 +841,8 @@ Perl_leave_scope(pTHX_ I32 base)
        case SAVEt_GP:                          /* scalar reference */
            ptr = SSPOPPTR;
            gv = (GV*)SSPOPPTR;
-           if (SvPVX(gv) && SvLEN(gv) > 0) {
-               Safefree(SvPVX(gv));
+           if (SvPVX_const(gv) && SvLEN(gv) > 0) {
+               Safefree(SvPVX_const(gv));
            }
            SvPV_set(gv, (char *)SSPOPPTR);
            SvCUR_set(gv, (STRLEN)SSPOPIV);
@@ -869,7 +868,7 @@ Perl_leave_scope(pTHX_ I32 base)
            break;
        case SAVEt_FREEPV:
            ptr = SSPOPPTR;
-           Safefree((char*)ptr);
+           Safefree(ptr);
            break;
        case SAVEt_CLEARSV:
            ptr = (void*)&PL_curpad[SSPOPLONG];
@@ -1095,7 +1094,7 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
                PL_op_desc[cx->blk_eval.old_op_type]);
        if (cx->blk_eval.old_namesv)
            PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
-                         SvPVX(cx->blk_eval.old_namesv));
+                         SvPVX_const(cx->blk_eval.old_namesv));
        PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
                PTR2UV(cx->blk_eval.old_eval_root));
        PerlIO_printf(Perl_debug_log, "BLK_EVAL.RETOP = 0x%"UVxf"\n",
@@ -1161,5 +1160,5 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
  * indent-tabs-mode: t
  * End:
  *
- * vim: ts=8 sts=4 sw=4 noet:
-*/
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */