add missing file from change#1943
[p5sagit/p5-mst-13.2.git] / pp_hot.c
index fcbdb14..859dcfb 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -863,9 +863,9 @@ PP(pp_match)
            }
        }
     }
-    safebase = (((gimme == G_ARRAY) || global || !rx->nparens)
-               && !PL_sawampersand);
-    safebase = safebase ? 0  : REXEC_COPY_STR ;
+    safebase = ((gimme != G_ARRAY && !global && rx->nparens)
+               || SvTEMP(TARG) || PL_sawampersand)
+               ? REXEC_COPY_STR : 0;
     if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
        SAVEINT(PL_multiline);
        PL_multiline = pm->op_pmflags & PMf_MULTILINE;
@@ -888,7 +888,7 @@ play_it_again:
                if (PL_screamfirst[BmRARE(rx->check_substr)] < 0)
                    goto nope;
 
-               b = HOP((U8*)s, rx->check_offset_min);
+               b = (char*)HOP((U8*)s, rx->check_offset_min);
                if (!(s = screaminstr(TARG, rx->check_substr, b - s, 0, &p, 0)))
                    goto nope;
 
@@ -904,7 +904,7 @@ play_it_again:
                goto yup;
            if (s && rx->check_offset_max < s - t) {
                ++BmUSEFUL(rx->check_substr);
-               s = HOP((U8*)s, -rx->check_offset_max);
+               s = (char*)HOP((U8*)s, -rx->check_offset_max);
            }
            else
                s = t;
@@ -913,7 +913,7 @@ play_it_again:
           beginning of match, and the match is anchored at s. */
        else if (!PL_multiline) {       /* Anchored near beginning of string. */
            I32 slen;
-           char *b = HOP((U8*)s, rx->check_offset_min);
+           char *b = (char*)HOP((U8*)s, rx->check_offset_min);
            if (*SvPVX(rx->check_substr) != *b
                || ((slen = SvCUR(rx->check_substr)) > 1
                    && memNE(SvPVX(rx->check_substr), b, slen)))
@@ -1258,8 +1258,12 @@ do_readline(void)
                IoFLAGS(io) |= IOf_START;
            }
            else if (type == OP_GLOB) {
-               if (!do_close(PL_last_in_gv, FALSE))
-                   warn("internal error: glob failed");
+               if (!do_close(PL_last_in_gv, FALSE) && ckWARN(WARN_CLOSED)) {
+                   warner(WARN_CLOSED,
+                          "glob failed (child exited with status %d%s)",
+                          STATUS_CURRENT >> 8,
+                          (STATUS_CURRENT & 0xFF) ? ", core dumped" : "");
+               }
            }
            if (gimme == G_SCALAR) {
                (void)SvOK_off(TARG);
@@ -1461,7 +1465,7 @@ PP(pp_iter)
 
     EXTEND(SP, 1);
     cx = &cxstack[cxstack_ix];
-    if (cx->cx_type != CXt_LOOP)
+    if (CxTYPE(cx) != CXt_LOOP)
        DIE("panic: pp_iter");
 
     av = cx->blk_loop.iterary;
@@ -1622,7 +1626,8 @@ PP(pp_subst)
                  && SvTYPE(rx->check_substr) == SVt_PVBM
                  && SvVALID(rx->check_substr)) 
                ? TARG : Nullsv);
-    safebase = (!rx->nparens && !PL_sawampersand) ? 0 : REXEC_COPY_STR;
+    safebase = (rx->nparens || SvTEMP(TARG) || PL_sawampersand)
+               ? REXEC_COPY_STR : 0;
     if (pm->op_pmflags & (PMf_MULTILINE|PMf_SINGLELINE)) {
        SAVEINT(PL_multiline);
        PL_multiline = pm->op_pmflags & PMf_MULTILINE;
@@ -1637,7 +1642,7 @@ PP(pp_subst)
                if (PL_screamfirst[BmRARE(rx->check_substr)] < 0)
                    goto nope;
 
-               b = HOP((U8*)s, rx->check_offset_min);
+               b = (char*)HOP((U8*)s, rx->check_offset_min);
                if (!(s = screaminstr(TARG, rx->check_substr, b - s, 0, &p, 0)))
                    goto nope;
            }
@@ -1647,7 +1652,7 @@ PP(pp_subst)
                goto nope;
            if (s && rx->check_offset_max < s - m) {
                ++BmUSEFUL(rx->check_substr);
-               s = HOP((U8*)s, -rx->check_offset_max);
+               s = (char*)HOP((U8*)s, -rx->check_offset_max);
            }
            else
                s = m;
@@ -1656,7 +1661,7 @@ PP(pp_subst)
           beginning of match, and the match is anchored at s. */
        else if (!PL_multiline) { /* Anchored at beginning of string. */
            I32 slen;
-           char *b = HOP((U8*)s, rx->check_offset_min);
+           char *b = (char*)HOP((U8*)s, rx->check_offset_min);
            if (*SvPVX(rx->check_substr) != *b
                || ((slen = SvCUR(rx->check_substr)) > 1
                    && memNE(SvPVX(rx->check_substr), b, slen)))
@@ -2268,12 +2273,14 @@ PP(pp_entersub)
        PUSHBLOCK(cx, CXt_SUB, MARK);
        PUSHSUB(cx);
        CvDEPTH(cv)++;
+       /* XXX This would be a natural place to set C<PL_compcv = cv> so
+        * that eval'' ops within this sub know the correct lexical space.
+        * Owing the speed considerations, we choose to search for the cv
+        * in doeval() instead.
+        */
        if (CvDEPTH(cv) < 2)
            (void)SvREFCNT_inc(cv);
        else {  /* save temporaries on recursion? */
-           if (CvDEPTH(cv) == 100 && ckWARN(WARN_RECURSION)
-                 && !(PERLDB_SUB && cv == GvCV(PL_DBsub)))
-               sub_crush_depth(cv);
            if (CvDEPTH(cv) > AvFILLp(padlist)) {
                AV *av;
                AV *newpad = newAV();
@@ -2373,6 +2380,13 @@ PP(pp_entersub)
                MARK++;
            }
        }
+       /* warning must come *after* we fully set up the context
+        * stuff so that __WARN__ handlers can safely dounwind()
+        * if they want to
+        */
+       if (CvDEPTH(cv) == 100 && ckWARN(WARN_RECURSION)
+           && !(PERLDB_SUB && cv == GvCV(PL_DBsub)))
+           sub_crush_depth(cv);
 #if 0
        DEBUG_S(PerlIO_printf(PerlIO_stderr(),
                              "%p entersub returning %p\n", thr, CvSTART(cv)));