label code in pp_ctl.c
Nicholas Clark [Thu, 26 Dec 2002 21:19:36 +0000 (21:19 +0000)]
Message-ID: <20021226211935.GE284@Bagpuss.unfortu.net>
(Integrated from change #18400 from maint-5.8)
p4raw-link: @18400 on //depot/maint-5.8/perl: ab4e87da5f15e988acf1c2de6c4dc8360964c519

p4raw-id: //depot/perl@18464
p4raw-integrated: from //depot/maint-5.8/perl@18400 'merge in' pp_ctl.c
(@18271..)

pp_ctl.c

index 5b2eabb..4ef44fd 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1015,6 +1015,16 @@ PP(pp_flop)
 
 /* Control. */
 
+static char *context_name[] = {
+    "pseudo-block",
+    "subroutine",
+    "eval",
+    "loop",
+    "substitution",
+    "block",
+    "format"
+};
+
 STATIC I32
 S_dopoptolabel(pTHX_ char *label)
 {
@@ -1025,30 +1035,16 @@ S_dopoptolabel(pTHX_ char *label)
        cx = &cxstack[i];
        switch (CxTYPE(cx)) {
        case CXt_SUBST:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting substitution via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_SUB:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting subroutine via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_FORMAT:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting format via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_EVAL:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting eval via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_NULL:
            if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting pseudo-block via %s",
-                       OP_NAME(PL_op));
-           return -1;
+               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting %s via %s",
+                       context_name[CxTYPE(cx)], OP_NAME(PL_op));
+           if (CxTYPE(cx) == CXt_NULL)
+               return -1;
+           break;
        case CXt_LOOP:
            if (!cx->blk_loop.label ||
              strNE(label, cx->blk_loop.label) ) {
@@ -1160,30 +1156,16 @@ S_dopoptoloop(pTHX_ I32 startingblock)
        cx = &cxstack[i];
        switch (CxTYPE(cx)) {
        case CXt_SUBST:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting substitution via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_SUB:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting subroutine via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_FORMAT:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting format via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_EVAL:
-           if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting eval via %s",
-                       OP_NAME(PL_op));
-           break;
        case CXt_NULL:
            if (ckWARN(WARN_EXITING))
-               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting pseudo-block via %s",
-                       OP_NAME(PL_op));
-           return -1;
+               Perl_warner(aTHX_ packWARN(WARN_EXITING), "Exiting %s via %s",
+                       context_name[CxTYPE(cx)], OP_NAME(PL_op));
+           if ((CxTYPE(cx)) == CXt_NULL)
+               return -1;
+           break;
        case CXt_LOOP:
            DEBUG_l( Perl_deb(aTHX_ "(Found loop #%ld)\n", (long)i));
            return i;