diff options
author | David Mitchell <davem@iabyn.com> | 2016-06-28 16:31:45 +0100 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2016-07-01 09:35:14 +0100 |
commit | 03e81cd36058f8d91a1a7b9dbe588f71ee37b274 (patch) | |
tree | d5855f10fae64734f537c9ff7d254b32fea18288 /pp_ctl.c | |
parent | 70b02e389c9f2b0bf1f1d601f841f25c606cebda (diff) | |
download | perl-03e81cd36058f8d91a1a7b9dbe588f71ee37b274.tar.gz |
tidy doeval_compile()
After the previous commit removed some dead code, the rest of the
code can be re-arranged to be slightly tidier. In particular, this
structure:
if (foo) {
...;
}
if (in_require) {
assert(foo);
croak(...);
}
becomes the logically equivalent
if (foo) {
...;
if (in_require) {
croak(...);
}
}
assert(!in_require);
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 21 |
1 files changed, 11 insertions, 10 deletions
@@ -3383,7 +3383,6 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) yystatus = (!in_require && CATCH_GET) ? S_try_yyparse(aTHX_ GRAMPROG) : yyparse(GRAMPROG); if (yystatus || PL_parser->error_count || !PL_eval_root) { - SV *namesv = NULL; /* initialise to avoid compiler warning */ PERL_CONTEXT *cx; SV *errsv; @@ -3392,6 +3391,7 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) * compilation, so the EVAL CX block has already been popped, and * various vars restored */ if (yystatus != 3) { + SV *namesv; if (PL_eval_root) { op_free(PL_eval_root); PL_eval_root = NULL; @@ -3404,18 +3404,19 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh) if (in_require) namesv = cx->blk_eval.old_namesv; CX_POP(cx); - } - errsv = ERRSV; - if (in_require) { - /* die_unwind() re-croaks when in require, having popped - * the require EVAL context. So we should never catch - * a require exception here */ - assert(yystatus != 3); - S_undo_inc_then_croak(aTHX_ namesv, errsv, FALSE); - NOT_REACHED; /* NOTREACHED */ + if (in_require) { + S_undo_inc_then_croak(aTHX_ namesv, ERRSV, FALSE); + NOT_REACHED; /* NOTREACHED */ + } } + /* die_unwind() re-croaks when in require, having popped the + * require EVAL context. So we should never catch a require + * exception here */ + assert(!in_require); + + errsv = ERRSV; if (!*(SvPV_nolen_const(errsv))) sv_setpvs(errsv, "Compilation error"); |