summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-03-08 18:35:48 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-03-08 18:35:48 +0000
commitfaa7e5bbaa1a624cf61859998ab6ab0a1323ed35 (patch)
tree517d38c6e942b647e70d697aa0ce84e049de56eb
parente4783991709775389a3fc70c841522b0165cd076 (diff)
downloadperl-faa7e5bbaa1a624cf61859998ab6ab0a1323ed35.tar.gz
do FILE should not see outside lexicals (from Rick Delaney
<rick@consumercontact.com>) p4raw-id: //depot/perl@5620
-rw-r--r--op.c3
-rw-r--r--pp_ctl.c5
-rwxr-xr-xt/comp/require.t15
3 files changed, 19 insertions, 4 deletions
diff --git a/op.c b/op.c
index bc07904755..689fc18aba 100644
--- a/op.c
+++ b/op.c
@@ -356,8 +356,9 @@ S_pad_findlex(pTHX_ char *name, PADOFFSET newoff, U32 seq, CV* startcv,
if (CxREALEVAL(cx))
saweval = i;
break;
+ case OP_DOFILE:
case OP_REQUIRE:
- /* require must have its own scope */
+ /* require/do must have their own scope */
return 0;
}
break;
diff --git a/pp_ctl.c b/pp_ctl.c
index edbe7b19ab..42811f5619 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2727,8 +2727,11 @@ S_doeval(pTHX_ int gimme, OP** startop)
av_store(comppadlist, 1, (SV*)PL_comppad);
CvPADLIST(PL_compcv) = comppadlist;
- if (!saveop || saveop->op_type != OP_REQUIRE)
+ if (!saveop ||
+ (saveop->op_type != OP_REQUIRE && saveop->op_type != OP_DOFILE))
+ {
CvOUTSIDE(PL_compcv) = (CV*)SvREFCNT_inc(caller);
+ }
SAVEFREESV(PL_compcv);
diff --git a/t/comp/require.t b/t/comp/require.t
index efce899edc..1d92687355 100755
--- a/t/comp/require.t
+++ b/t/comp/require.t
@@ -7,7 +7,7 @@ BEGIN {
# don't make this lexical
$i = 1;
-print "1..19\n";
+print "1..20\n";
sub do_require {
%INC = ();
@@ -113,7 +113,18 @@ do_require "1";
print "# $@\nnot " if $@;
print "ok ",$i++,"\n";
-END { 1 while unlink 'bleah.pm'; }
+# do FILE shouldn't see any outside lexicals
+my $x = "ok $i\n";
+write_file("bleah.do", <<EOT);
+\$x = "not ok $i\\n";
+EOT
+do "bleah.do";
+dofile();
+sub dofile { do "bleah.do"; };
+print $x;
+$i++;
+
+END { 1 while unlink 'bleah.pm'; 1 while unlink 'bleah.do'; }
# ***interaction with pod (don't put any thing after here)***