This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Inside require() $^S was always left undefined.
authorIlya Zakharevich <ilya@math.berkeley.edu>
Wed, 27 Sep 2000 18:54:49 +0000 (14:54 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 3 Oct 2000 00:04:00 +0000 (00:04 +0000)
Subject: Re: Tiny 2-byte change to fix debugger's eval bug
Message-ID: <20000927185449.A24927@monk.mps.ohio-state.edu>

p4raw-id: //depot/perl@7120

cop.h
mg.c
pp_ctl.c
util.c

diff --git a/cop.h b/cop.h
index 5b47884..6e8bd91 100644 (file)
--- a/cop.h
+++ b/cop.h
@@ -433,6 +433,7 @@ L<perlcall>.
 #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 */
+#define EVAL_INREQUIRE 8       /* The code is being required. */
 
 /* Support for switching (stack and block) contexts.
  * This ensures magic doesn't invalidate local stack and cx pointers.
diff --git a/mg.c b/mg.c
index 7712cac..1cfaf05 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -575,9 +575,7 @@ Perl_magic_get(pTHX_ SV *sv, MAGIC *mg)
            if (PL_lex_state != LEX_NOTPARSING)
                (void)SvOK_off(sv);
            else if (PL_in_eval)
-               sv_setiv(sv, 1);
-           else
-               sv_setiv(sv, 0);
+               sv_setiv(sv, PL_in_eval & ~(EVAL_INREQUIRE));
        }
        break;
     case '\024':               /* ^T */
index 254cce8..c949e78 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2728,7 +2728,9 @@ S_doeval(pTHX_ int gimme, OP** startop)
     AV* comppadlist;
     I32 i;
 
-    PL_in_eval = EVAL_INEVAL;
+    PL_in_eval = ((saveop && saveop->op_type == OP_REQUIRE)
+                 ? (EVAL_INREQUIRE | (PL_in_eval & EVAL_INEVAL))
+                 : EVAL_INEVAL);
 
     PUSHMARK(SP);
 
@@ -2891,6 +2893,7 @@ S_doeval(pTHX_ int gimme, OP** startop)
     CvDEPTH(PL_compcv) = 1;
     SP = PL_stack_base + POPMARK;              /* pop original mark */
     PL_op = saveop;                    /* The caller may need it. */
+    PL_lex_state = LEX_NOTPARSING;     /* $^S needs this. */
 #ifdef USE_THREADS
     MUTEX_LOCK(&PL_eval_mutex);
     PL_eval_owner = 0;
diff --git a/util.c b/util.c
index 6123321..12c30a0 100644 (file)
--- a/util.c
+++ b/util.c
@@ -3606,7 +3606,7 @@ Perl_new_struct_thread(pTHX_ struct perl_thread *t)
 
     JMPENV_BOOTSTRAP;
 
-    PL_in_eval = EVAL_NULL;    /* ~(EVAL_INEVAL|EVAL_WARNONLY|EVAL_KEEPERR) */
+    PL_in_eval = EVAL_NULL;    /* ~(EVAL_INEVAL|EVAL_WARNONLY|EVAL_KEEPERR|EVAL_INREQUIRE) */
     PL_restartop = 0;
 
     PL_statname = NEWSV(66,0);