This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_goto: document the different branches
authorDavid Mitchell <davem@iabyn.com>
Fri, 6 Sep 2013 14:54:10 +0000 (15:54 +0100)
committerDavid Mitchell <davem@iabyn.com>
Fri, 6 Sep 2013 14:55:40 +0000 (15:55 +0100)
Te various different forms of goto (and dump) take different branches
through this big function. Document which branches handle which variants.
Also document the use of OPf_SPECIAL in OP_DUMP.

op.h
pp_ctl.c

diff --git a/op.h b/op.h
index 038d908..08d46f9 100644 (file)
--- a/op.h
+++ b/op.h
@@ -143,6 +143,7 @@ Deprecated.  Use C<GIMME_V> instead.
                                    - After ck_glob, use Perl glob function
                                 */
                                 /*  On OP_PADRANGE, push @_ */
+                                /*  On OP_DUMP, has no label */
 
 /* old names; don't use in new code, but don't break them, either */
 #define OPf_LIST       OPf_WANT_LIST
index d091e29..24a8cd6 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2776,7 +2776,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
     return 0;
 }
 
-PP(pp_goto)
+PP(pp_goto) /* also pp_dump */
 {
     dVAR; dSP;
     OP *retop = NULL;
@@ -2791,6 +2791,8 @@ PP(pp_goto)
     static const char* const must_have_label = "goto must have label";
 
     if (PL_op->op_flags & OPf_STACKED) {
+        /* goto EXPR  or  goto &foo */
+
        SV * const sv = POPs;
        SvGETMAGIC(sv);
 
@@ -2986,11 +2988,13 @@ PP(pp_goto)
            }
        }
        else {
+            /* goto EXPR */
            label       = SvPV_nomg_const(sv, label_len);
             label_flags = SvUTF8(sv);
        }
     }
     else if (!(PL_op->op_flags & OPf_SPECIAL)) {
+        /* goto LABEL  or  dump LABEL */
        label       = cPVOP->op_pv;
         label_flags = (cPVOP->op_private & OPpPV_IS_UTF8) ? SVf_UTF8 : 0;
         label_len   = strlen(label);