Skip processing a file if the file to be opened is '-'
[p5sagit/p5-mst-13.2.git] / cop.h
diff --git a/cop.h b/cop.h
index 88749fb..88627d6 100644 (file)
--- a/cop.h
+++ b/cop.h
 struct cop {
     BASEOP
     char *     cop_label;      /* label for this construct */
+#ifdef USE_ITHREADS
+    char *     cop_stashpv;    /* package line was compiled in */
+    char *     cop_file;       /* file name the following line # is from */
+#else
     HV *       cop_stash;      /* package line was compiled in */
     GV *       cop_filegv;     /* file the following line # is from */
+#endif
     U32                cop_seq;        /* parse sequence number */
     I32                cop_arybase;    /* array base this line was compiled with */
     line_t      cop_line;       /* line # of this command */
@@ -20,6 +25,44 @@ struct cop {
 
 #define Nullcop Null(COP*)
 
+#ifdef USE_ITHREADS
+#  define CopFILE(c)           ((c)->cop_file)
+#  define CopFILEGV(c)         (CopFILE(c) \
+                                ? gv_fetchfile(CopFILE(c)) : Nullgv)
+#  define CopFILE_set(c,pv)    ((c)->cop_file = savepv(pv))    /* XXX */
+#  define CopFILESV(c)         (CopFILE(c) \
+                                ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
+#  define CopFILEAV(c)         (CopFILE(c) \
+                                ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
+#  define CopSTASHPV(c)                ((c)->cop_stashpv)
+#  define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = savepv(pv)) /* XXX */
+#  define CopSTASH(c)          (CopSTASHPV(c) \
+                                ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
+#  define CopSTASH_set(c,hv)   CopSTASHPV_set(c, HvNAME(hv))
+#  define CopSTASH_eq(c,hv)    (hv                                     \
+                                && (CopSTASHPV(c) == HvNAME(hv)        \
+                                    || (CopSTASHPV(c) && HvNAME(hv)    \
+                                        && strEQ(CopSTASHPV(c), HvNAME(hv)))))
+#else
+#  define CopFILEGV(c)         ((c)->cop_filegv)
+#  define CopFILEGV_set(c,gv)  ((c)->cop_filegv = gv)
+#  define CopFILE_set(c,pv)    ((c)->cop_filegv = gv_fetchfile(pv))
+#  define CopFILESV(c)         (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
+#  define CopFILEAV(c)         (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
+#  define CopFILE(c)           (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
+#  define CopSTASH(c)          ((c)->cop_stash)
+#  define CopSTASH_set(c,hv)   ((c)->cop_stash = hv)
+#  define CopSTASHPV(c)                (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
+#  define CopSTASHPV_set(c,pv) CopSTASH_set(c, gv_stashpv(pv,GV_ADD))
+#  define CopSTASH_eq(c,hv)    (CopSTASH(c) == hv)
+#endif /* USE_ITHREADS */
+
+#define CopSTASH_ne(c,hv)      (!CopSTASH_eq(c,hv))
+#define CopLINE(c)             ((c)->cop_line)
+#define CopLINE_inc(c)         (++CopLINE(c))
+#define CopLINE_dec(c)         (--CopLINE(c))
+#define CopLINE_set(c,l)       (CopLINE(c) = (l))
+
 /*
  * Here we have some enormously heavy (or at least ponderous) wizardry.
  */
@@ -62,7 +105,8 @@ struct block_sub {
     } STMT_END
 #endif /* USE_THREADS */
 
-#define POPSUB(cx)                                                     \
+#define POPSUB(cx,sv)                                                  \
+    STMT_START {                                                       \
        if (cx->blk_sub.hasargs) {                                      \
            POPSAVEARRAY();                                             \
            /* abandon @_ if it got reified */                          \
@@ -75,10 +119,16 @@ struct block_sub {
                PL_curpad[0] = (SV*)cx->blk_sub.argarray;               \
            }                                                           \
        }                                                               \
-       if (cx->blk_sub.cv) {                                           \
-           if (!(CvDEPTH(cx->blk_sub.cv) = cx->blk_sub.olddepth))      \
-               SvREFCNT_dec(cx->blk_sub.cv);                           \
-       }
+       sv = (SV*)cx->blk_sub.cv;                                       \
+       if (sv && (CvDEPTH((CV*)sv) = cx->blk_sub.olddepth))            \
+           sv = Nullsv;                                                \
+    } STMT_END
+
+#define LEAVESUB(sv)                                                   \
+    STMT_START {                                                       \
+       if (sv)                                                         \
+           SvREFCNT_dec(sv);                                           \
+    } STMT_END
 
 #define POPFORMAT(cx)                                                  \
        setdefout(cx->blk_sub.dfoutgv);                                 \
@@ -289,7 +339,6 @@ struct context {
 #define G_NOARGS       8       /* Don't construct a @_ array. */
 #define G_KEEPERR      16      /* Append errors to $@, don't overwrite it */
 #define G_NODEBUG      32      /* Disable debugging at toplevel.  */
-#define G_NOCATCH      64       /* Don't do CATCH_SET() */
 
 /* flag bits for PL_in_eval */
 #define EVAL_NULL      0       /* not in an eval */
@@ -321,7 +370,7 @@ struct stackinfo {
     I32                        si_type;        /* type of runlevel */
     struct stackinfo * si_prev;
     struct stackinfo * si_next;
-    I32 *              si_markbase;    /* where markstack begins for us.
+    I32                        si_markoff;     /* offset where markstack begins for us.
                                         * currently used only with DEBUGGING,
                                         * but not #ifdef-ed for bincompat */
 };
@@ -333,9 +382,10 @@ typedef struct stackinfo PERL_SI;
 #define cxstack_max    (PL_curstackinfo->si_cxmax)
 
 #ifdef DEBUGGING
-#  define      SET_MARKBASE PL_curstackinfo->si_markbase = PL_markstack_ptr
+#  define      SET_MARK_OFFSET \
+    PL_curstackinfo->si_markoff = PL_markstack_ptr - PL_markstack
 #else
-#  define      SET_MARKBASE NOOP
+#  define      SET_MARK_OFFSET NOOP
 #endif
 
 #define PUSHSTACKi(type) \
@@ -351,7 +401,7 @@ typedef struct stackinfo PERL_SI;
        AvFILLp(next->si_stack) = 0;                                    \
        SWITCHSTACK(PL_curstack,next->si_stack);                        \
        PL_curstackinfo = next;                                         \
-       SET_MARKBASE;                                                   \
+       SET_MARK_OFFSET;                                                \
     } STMT_END
 
 #define PUSHSTACK PUSHSTACKi(PERLSI_UNKNOWN)