From faef01704ba77a858827d4e793b056731d6e6832 Mon Sep 17 00:00:00 2001 From: Hugo van der Sanden Date: Sun, 23 May 1999 17:35:07 +0100 Subject: name PL_in_eval bits Message-Id: <199905231535.QAA00032@crypt.compulink.co.uk> p4raw-id: //depot/perl@3457 --- cop.h | 6 ++++++ op.c | 8 +++++--- perl.c | 4 ++-- pp_ctl.c | 8 ++++---- toke.c | 6 +++--- util.c | 2 +- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cop.h b/cop.h index 6529974cd1..0f029ca77d 100644 --- a/cop.h +++ b/cop.h @@ -298,6 +298,12 @@ struct context { #define G_KEEPERR 16 /* Append errors to $@, don't overwrite it */ #define G_NODEBUG 32 /* Disable debugging at toplevel. */ +/* flag bits for PL_in_eval */ +#define EVAL_NULL 0 /* not in an eval */ +#define EVAL_INEVAL 1 /* some enclosing scope is an eval */ +#define EVAL_WARNONLY 2 /* used by yywarn() when calling yyerror() */ +#define EVAL_KEEPERR 4 /* set by perl_call_sv if G_KEEPERR */ + /* Support for switching (stack and block) contexts. * This ensures magic doesn't invalidate local stack and cx pointers. */ diff --git a/op.c b/op.c index 8f19121091..488766b2e2 100644 --- a/op.c +++ b/op.c @@ -136,7 +136,7 @@ assertref(OP *o) SV *msg = sv_2mortal( newSVpvf("(Did you mean $ or @ instead of %c?)\n", type == OP_ENTERSUB ? '&' : '%')); - if (PL_in_eval & 2) + if (PL_in_eval & EVAL_WARNONLY) warn("%_", msg); else if (PL_in_eval) sv_catsv(GvSV(PL_errgv), msg); @@ -1764,7 +1764,9 @@ newPROG(OP *o) if (PL_in_eval) { if (PL_eval_root) return; - PL_eval_root = newUNOP(OP_LEAVEEVAL, ((PL_in_eval & 4) ? OPf_SPECIAL : 0), o); + PL_eval_root = newUNOP(OP_LEAVEEVAL, + ((PL_in_eval & EVAL_KEEPERR) + ? OPf_SPECIAL : 0), o); PL_eval_start = linklist(PL_eval_root); PL_eval_root->op_next = 0; peep(PL_eval_start); @@ -3997,7 +3999,7 @@ newSUB(I32 floor, OP *o, OP *proto, OP *block) if (strEQ(s, "BEGIN")) { char *not_safe = "BEGIN not safe after errors--compilation aborted"; - if (PL_in_eval & 4) + if (PL_in_eval & EVAL_KEEPERR) croak(not_safe); else { /* force display of errors found but not reported */ diff --git a/perl.c b/perl.c index 09da6681cb..cbe1d22d8b 100644 --- a/perl.c +++ b/perl.c @@ -1315,9 +1315,9 @@ perl_call_sv(SV *sv, I32 flags) PUSHEVAL(cx, 0, 0); PL_eval_root = PL_op; /* Only needed so that goto works right. */ - PL_in_eval = 1; + PL_in_eval = EVAL_INEVAL; if (flags & G_KEEPERR) - PL_in_eval |= 4; + PL_in_eval |= EVAL_KEEPERR; else sv_setpv(ERRSV,""); } diff --git a/pp_ctl.c b/pp_ctl.c index 19bfb2183c..3d27aa5146 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1335,7 +1335,7 @@ die_where(char *message, STRLEN msglen) SV **newsp; if (message) { - if (PL_in_eval & 4) { + if (PL_in_eval & EVAL_KEEPERR) { SV **svp; svp = hv_fetch(ERRHV, message, msglen, TRUE); @@ -2612,7 +2612,7 @@ doeval(int gimme, OP** startop) AV* comppadlist; I32 i; - PL_in_eval = 1; + PL_in_eval = EVAL_INEVAL; PUSHMARK(SP); @@ -2691,7 +2691,7 @@ doeval(int gimme, OP** startop) SvREFCNT_dec(PL_rs); PL_rs = newSVpvn("\n", 1); if (saveop && saveop->op_flags & OPf_SPECIAL) - PL_in_eval |= 4; + PL_in_eval |= EVAL_KEEPERR; else sv_setpv(ERRSV,""); if (yyparse() || PL_error_count || !PL_eval_root) { @@ -3145,7 +3145,7 @@ PP(pp_entertry) PUSHEVAL(cx, 0, 0); PL_eval_root = PL_op; /* Only needed so that goto works right. */ - PL_in_eval = 1; + PL_in_eval = EVAL_INEVAL; sv_setpv(ERRSV,""); PUTBACK; return DOCATCH(PL_op->op_next); diff --git a/toke.c b/toke.c index 0105fe1265..1ac96a1d0d 100644 --- a/toke.c +++ b/toke.c @@ -6360,9 +6360,9 @@ yywarn(char *s) { dTHR; --PL_error_count; - PL_in_eval |= 2; + PL_in_eval |= EVAL_WARNONLY; yyerror(s); - PL_in_eval &= ~2; + PL_in_eval &= ~EVAL_WARNONLY; return 0; } @@ -6425,7 +6425,7 @@ yyerror(char *s) (int)PL_multi_open,(int)PL_multi_close,(long)PL_multi_start); PL_multi_end = 0; } - if (PL_in_eval & 2) + if (PL_in_eval & EVAL_WARNONLY) warn("%_", msg); else if (PL_in_eval) sv_catsv(ERRSV, msg); diff --git a/util.c b/util.c index d9076d8db9..67c030b056 100644 --- a/util.c +++ b/util.c @@ -2959,7 +2959,7 @@ new_struct_thread(struct perl_thread *t) PL_start_env.je_mustcatch = TRUE; PL_top_env = &PL_start_env; - PL_in_eval = FALSE; + PL_in_eval = EVAL_NULL; /* ~(EVAL_INEVAL|EVAL_WARNONLY|EVAL_KEEPERR) */ PL_restartop = 0; PL_statname = NEWSV(66,0); -- cgit v1.2.1