Split struct block_sub into struct block_sub and struct block_format.
Nicholas Clark [Sun, 20 Jan 2008 19:56:21 +0000 (19:56 +0000)]
(CXt_SUB and CXt_FORMAT were using some comon members, but some members
were only for one or the other.)

p4raw-id: //depot/perl@33014

cop.h
pp_sys.c
scope.c
sv.c

diff --git a/cop.h b/cop.h
index 5c80173..778ffac 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -280,15 +280,26 @@ struct cop {
 /* subroutine context */
 struct block_sub {
     CV *       cv;
-    GV *       gv;
-    GV *       dfoutgv;
+    OP *       retop;  /* op to execute on exit from sub */
+    U8         hasargs;
+    U8         lval;           /* XXX merge lval and hasargs? */
+    /* Above here is the same for sub and format.  */
     AV *       savearray;
     AV *       argarray;
     I32                olddepth;
-    U8         hasargs;
-    U8         lval;           /* XXX merge lval and hasargs? */
     PAD                *oldcomppad;
+};
+
+
+/* format context */
+struct block_format {
+    CV *       cv;
     OP *       retop;  /* op to execute on exit from sub */
+    U8         hasargs;
+    U8         lval;           /* XXX merge lval and hasargs? */
+    /* Above here is the same for sub and format.  */
+    GV *       gv;
+    GV *       dfoutgv;
 };
 
 /* base for the next two macros. Don't use directly.
@@ -323,12 +334,12 @@ struct block_sub {
 
 
 #define PUSHFORMAT(cx, retop)                                          \
-       cx->blk_sub.cv = cv;                                            \
-       cx->blk_sub.gv = gv;                                            \
-       cx->blk_sub.retop = (retop);                                    \
-       cx->blk_sub.hasargs = 0;                                        \
-       cx->blk_sub.dfoutgv = PL_defoutgv;                              \
-       SvREFCNT_inc_void(cx->blk_sub.dfoutgv)
+       cx->blk_format.cv = cv;                                         \
+       cx->blk_format.gv = gv;                                         \
+       cx->blk_format.retop = (retop);                                 \
+       cx->blk_format.hasargs = 0;                                     \
+       cx->blk_format.dfoutgv = PL_defoutgv;                           \
+       SvREFCNT_inc_void(cx->blk_format.dfoutgv)
 
 #define POP_SAVEARRAY()                                                \
     STMT_START {                                                       \
@@ -378,8 +389,8 @@ struct block_sub {
     } STMT_END
 
 #define POPFORMAT(cx)                                                  \
-       setdefout(cx->blk_sub.dfoutgv);                                 \
-       SvREFCNT_dec(cx->blk_sub.dfoutgv);
+       setdefout(cx->blk_format.dfoutgv);                              \
+       SvREFCNT_dec(cx->blk_format.dfoutgv);
 
 /* eval context */
 struct block_eval {
@@ -532,6 +543,7 @@ struct block {
 
     union {
        struct block_sub        blku_sub;
+       struct block_format     blku_format;
        struct block_eval       blku_eval;
        struct block_loop       blku_loop;
        struct block_givwhen    blku_givwhen;
@@ -544,6 +556,7 @@ struct block {
 #define blk_oldpm      cx_u.cx_blk.blku_oldpm
 #define blk_gimme      cx_u.cx_blk.blku_gimme
 #define blk_sub                cx_u.cx_blk.blk_u.blku_sub
+#define blk_format     cx_u.cx_blk.blk_u.blku_format
 #define blk_eval       cx_u.cx_blk.blk_u.blku_eval
 #define blk_loop       cx_u.cx_blk.blk_u.blku_loop
 #define blk_givwhen    cx_u.cx_blk.blk_u.blku_givwhen
index b8fa1a9..d73772b 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1304,7 +1304,7 @@ PP(pp_enterwrite)
 PP(pp_leavewrite)
 {
     dVAR; dSP;
-    GV * const gv = cxstack[cxstack_ix].blk_sub.gv;
+    GV * const gv = cxstack[cxstack_ix].blk_format.gv;
     register IO * const io = GvIOp(gv);
     PerlIO *ofp;
     PerlIO *fp;
diff --git a/scope.c b/scope.c
index c074b69..b5925f7 100644 (file)
--- a/scope.c
+++ b/scope.c
@@ -1046,16 +1046,16 @@ Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
     case CXt_BLOCK:
        break;
     case CXt_FORMAT:
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
-               PTR2UV(cx->blk_sub.cv));
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
-               PTR2UV(cx->blk_sub.gv));
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
-               PTR2UV(cx->blk_sub.dfoutgv));
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
-               (int)cx->blk_sub.hasargs);
-       PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
-               PTR2UV(cx->blk_sub.retop));
+       PerlIO_printf(Perl_debug_log, "BLK_FORMAT.CV = 0x%"UVxf"\n",
+               PTR2UV(cx->blk_format.cv));
+       PerlIO_printf(Perl_debug_log, "BLK_FORMAT.GV = 0x%"UVxf"\n",
+               PTR2UV(cx->blk_format.gv));
+       PerlIO_printf(Perl_debug_log, "BLK_FORMAT.DFOUTGV = 0x%"UVxf"\n",
+               PTR2UV(cx->blk_format.dfoutgv));
+       PerlIO_printf(Perl_debug_log, "BLK_FORMAT.HASARGS = %d\n",
+               (int)cx->blk_format.hasargs);
+       PerlIO_printf(Perl_debug_log, "BLK_FORMAT.RETOP = 0x%"UVxf"\n",
+               PTR2UV(cx->blk_format.retop));
        break;
     case CXt_SUB:
        PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
diff --git a/sv.c b/sv.c
index 543558d..3ae7b75 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -10558,9 +10558,9 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param)
                                                     param);
                break;
            case CXt_FORMAT:
-               ncx->blk_sub.cv         = cv_dup(ncx->blk_sub.cv, param);
-               ncx->blk_sub.gv         = gv_dup(ncx->blk_sub.gv, param);
-               ncx->blk_sub.dfoutgv    = gv_dup_inc(ncx->blk_sub.dfoutgv,
+               ncx->blk_format.cv      = cv_dup(ncx->blk_format.cv, param);
+               ncx->blk_format.gv      = gv_dup(ncx->blk_format.gv, param);
+               ncx->blk_format.dfoutgv = gv_dup_inc(ncx->blk_format.dfoutgv,
                                                     param);
                break;
            case CXt_BLOCK: