This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix to first problem causing Cygwin Perl to fail to build
[perl5.git] / pp_hot.c
index 1e167a5..cbb35a3 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -120,6 +120,12 @@ PP(pp_sassign)
        SV * const temp = left;
        left = right; right = temp;
     }
+    else if (PL_op->op_private & OPpASSIGN_STATE) {
+       if (SvPADSTALE(right))
+           SvPADSTALE_off(right);
+       else
+           RETURN; /* ignore assignment */
+    }
     if (PL_tainting && PL_tainted && !SvTAINTED(left))
        TAINT_NOT;
     if (PL_op->op_private & OPpASSIGN_CV_TO_GV) {
@@ -273,7 +279,8 @@ PP(pp_padsv)
     XPUSHs(TARG);
     if (PL_op->op_flags & OPf_MOD) {
        if (PL_op->op_private & OPpLVAL_INTRO)
-           SAVECLEARSV(PAD_SVl(PL_op->op_targ));
+           if (!(PL_op->op_private & OPpPAD_STATE))
+               SAVECLEARSV(PAD_SVl(PL_op->op_targ));
         if (PL_op->op_private & OPpDEREF) {
            PUTBACK;
            vivify_ref(PAD_SVl(PL_op->op_targ), PL_op->op_private & OPpDEREF);
@@ -410,7 +417,7 @@ PP(pp_defined)
     register SV* sv;
     bool defined;
     const int op_type = PL_op->op_type;
-    const int is_dor = (op_type == OP_DOR || op_type == OP_DORASSIGN);
+    const bool is_dor = (op_type == OP_DOR || op_type == OP_DORASSIGN);
 
     if (is_dor) {
         sv = TOPs;
@@ -1073,6 +1080,12 @@ PP(pp_aassign)
            }
        }
     }
+    if (PL_op->op_private & OPpASSIGN_STATE) {
+       if (SvPADSTALE(*firstlelem))
+           SvPADSTALE_off(*firstlelem);
+       else
+           RETURN; /* ignore assignment */
+    }
 
     relem = firstrelem;
     lelem = firstlelem;
@@ -1924,7 +1937,9 @@ PP(pp_iter)
            /* string increment */
            register SV* cur = cx->blk_loop.iterlval;
            STRLEN maxlen = 0;
-           const char *max = SvOK((SV*)av) ? SvPV_const((SV*)av, maxlen) : "";
+           const char *max =
+             SvOK((SV*)av) ?
+             SvPV_const((SV*)av, maxlen) : (const char *)"";
            if (!SvNIOK(cur) && SvCUR(cur) <= maxlen) {
                if (SvREFCNT(*itersvp) == 1 && !SvMAGICAL(*itersvp)) {
                    /* safe to reuse old SV */
@@ -2290,13 +2305,13 @@ PP(pp_subst)
 #endif
        rxtainted |= RX_MATCH_TAINTED(rx);
        dstr = newSVpvn(m, s-m);
+       SAVEFREESV(dstr);
        if (DO_UTF8(TARG))
            SvUTF8_on(dstr);
        PL_curpm = pm;
        if (!c) {
            register PERL_CONTEXT *cx;
            SPAGAIN;
-           (void)ReREFCNT_inc(rx);
            PUSHSUBST(cx);
            RETURNOP(cPMOP->op_pmreplroot);
        }
@@ -2347,7 +2362,6 @@ PP(pp_subst)
        SvLEN_set(TARG, SvLEN(dstr));
        doutf8 |= DO_UTF8(dstr);
        SvPV_set(dstr, NULL);
-       sv_free(dstr);
 
        TAINT_IF(rxtainted & 1);
        SPAGAIN;
@@ -2504,7 +2518,7 @@ PP(pp_leavesublv)
 
     TAINT_NOT;
 
-    if (cx->blk_sub.lval & OPpENTERSUB_INARGS) {
+    if (CX_SUB_LVAL_INARGS(cx)) {
        /* We are an argument to a function or grep().
         * This kind of lvalueness was legal before lvalue
         * subroutines too, so be backward compatible:
@@ -2531,7 +2545,7 @@ PP(pp_leavesublv)
            }
        }
     }
-    else if (cx->blk_sub.lval) {     /* Leave it as it is if we can. */
+    else if (CX_SUB_LVAL(cx)) {     /* Leave it as it is if we can. */
        /* Here we go for robustness, not for speed, so we change all
         * the refcounts so the caller gets a live guy. Cannot set
         * TEMP, so sv_2mortal is out of question. */
@@ -2781,7 +2795,7 @@ try_autoload:
            else {
                sub_name = sv_newmortal();
                gv_efullname3(sub_name, gv, NULL);
-               DIE(aTHX_ "Undefined subroutine &%"SVf" called", sub_name);
+               DIE(aTHX_ "Undefined subroutine &%"SVf" called", (void*)sub_name);
            }
        }
        if (!cv)
@@ -2819,8 +2833,7 @@ try_autoload:
        }
        SAVECOMPPAD();
        PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
-       if (hasargs)
-       {
+       if (hasargs) {
            AV* const av = (AV*)PAD_SVl(0);
            if (AvREAL(av)) {
                /* @_ is normally not REAL--this should only ever
@@ -2871,42 +2884,43 @@ try_autoload:
        RETURNOP(CvSTART(cv));
     }
     else {
-           I32 markix = TOPMARK;
+       I32 markix = TOPMARK;
 
-           PUTBACK;
+       PUTBACK;
 
-           if (!hasargs) {
-               /* Need to copy @_ to stack. Alternative may be to
-                * switch stack to @_, and copy return values
-                * back. This would allow popping @_ in XSUB, e.g.. XXXX */
-               AV * const av = GvAV(PL_defgv);
-               const I32 items = AvFILLp(av) + 1;   /* @_ is not tieable */
-
-               if (items) {
-                   /* Mark is at the end of the stack. */
-                   EXTEND(SP, items);
-                   Copy(AvARRAY(av), SP + 1, items, SV*);
-                   SP += items;
-                   PUTBACK ;           
-               }
-           }
-           /* We assume first XSUB in &DB::sub is the called one. */
-           if (PL_curcopdb) {
-               SAVEVPTR(PL_curcop);
-               PL_curcop = PL_curcopdb;
-               PL_curcopdb = NULL;
-           }
-           /* Do we need to open block here? XXXX */
+       if (!hasargs) {
+           /* Need to copy @_ to stack. Alternative may be to
+            * switch stack to @_, and copy return values
+            * back. This would allow popping @_ in XSUB, e.g.. XXXX */
+           AV * const av = GvAV(PL_defgv);
+           const I32 items = AvFILLp(av) + 1;   /* @_ is not tieable */
+
+           if (items) {
+               /* Mark is at the end of the stack. */
+               EXTEND(SP, items);
+               Copy(AvARRAY(av), SP + 1, items, SV*);
+               SP += items;
+               PUTBACK ;               
+           }
+       }
+       /* We assume first XSUB in &DB::sub is the called one. */
+       if (PL_curcopdb) {
+           SAVEVPTR(PL_curcop);
+           PL_curcop = PL_curcopdb;
+           PL_curcopdb = NULL;
+       }
+       /* Do we need to open block here? XXXX */
+       if (CvXSUB(cv)) /* XXX this is supposed to be true */
            (void)(*CvXSUB(cv))(aTHX_ cv);
 
-           /* Enforce some sanity in scalar context. */
-           if (gimme == G_SCALAR && ++markix != PL_stack_sp - PL_stack_base ) {
-               if (markix > PL_stack_sp - PL_stack_base)
-                   *(PL_stack_base + markix) = &PL_sv_undef;
-               else
-                   *(PL_stack_base + markix) = *PL_stack_sp;
-               PL_stack_sp = PL_stack_base + markix;
-           }
+       /* Enforce some sanity in scalar context. */
+       if (gimme == G_SCALAR && ++markix != PL_stack_sp - PL_stack_base ) {
+           if (markix > PL_stack_sp - PL_stack_base)
+               *(PL_stack_base + markix) = &PL_sv_undef;
+           else
+               *(PL_stack_base + markix) = *PL_stack_sp;
+           PL_stack_sp = PL_stack_base + markix;
+       }
        LEAVE;
        return NORMAL;
     }
@@ -2921,7 +2935,7 @@ Perl_sub_crush_depth(pTHX_ CV *cv)
        SV* const tmpstr = sv_newmortal();
        gv_efullname3(tmpstr, CvGV(cv), NULL);
        Perl_warner(aTHX_ packWARN(WARN_RECURSION), "Deep recursion on subroutine \"%"SVf"\"",
-               tmpstr);
+                   (void*)tmpstr);
     }
 }
 
@@ -2937,7 +2951,9 @@ PP(pp_aelem)
     SV *sv;
 
     if (SvROK(elemsv) && !SvGAMAGIC(elemsv) && ckWARN(WARN_MISC))
-       Perl_warner(aTHX_ packWARN(WARN_MISC), "Use of reference \"%"SVf"\" as array index", elemsv);
+       Perl_warner(aTHX_ packWARN(WARN_MISC),
+                   "Use of reference \"%"SVf"\" as array index",
+                   (void*)elemsv);
     if (elem > 0)
        elem -= CopARYBASE_get(PL_curcop);
     if (SvTYPE(av) != SVt_PVAV)