From: Jarkko Hietaniemi Date: Mon, 22 Oct 2001 12:00:23 +0000 (+0000) Subject: Integrate changes #12549 and #12550 from maintperl; X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f558d5af046340f7a95617ab54ffef1ba978891c;p=p5sagit%2Fp5-mst-13.2.git Integrate changes #12549 and #12550 from maintperl; readline() doesn't work with our variables; it confuses them with my variables (change#4227 was incomplete) p4raw-link: @12549 on //depot/maint-5.6/perl: 5e948b4e169e88676c1f1359a0a62d670c4b4221 p4raw-link: @4227 on //depot/perl: 77ca0c92d2c0e47301d906d355d9ab3afb6f6bcb p4raw-id: //depot/perl@12561 p4raw-integrated: from //depot/maint-5.6/perl@12558 'copy in' t/base/rs.t (@8152..) 'edit in' toke.c (@12549..) --- diff --git a/t/base/rs.t b/t/base/rs.t index e470f3a..306d646 100755 --- a/t/base/rs.t +++ b/t/base/rs.t @@ -1,7 +1,7 @@ #!./perl # Test $! -print "1..14\n"; +print "1..16\n"; $teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n"; @@ -86,9 +86,7 @@ $/ = \$foo; $bar = ; if ($bar eq "78") {print "ok 10\n";} else {print "not ok 10\n";} -# Get rid of the temp file close TESTFILE; -unlink "./foo"; # Now for the tricky bit--full record reading if ($^O eq 'VMS') { @@ -130,3 +128,35 @@ if ($^O eq 'VMS') { # put their own tests in) so we just punt foreach $test (11..14) {print "ok $test # skipped on non-VMS system\n"}; } + +$/ = "\n"; + +# see if open/readline/close work on our and my variables +{ + if (open our $T, "./foo") { + my $line = <$T>; + print "# $line\n"; + length($line) == 40 or print "not "; + close $T or print "not "; + } + else { + print "not "; + } + print "ok 15\n"; +} + +{ + if (open my $T, "./foo") { + my $line = <$T>; + print "# $line\n"; + length($line) == 40 or print "not "; + close $T or print "not "; + } + else { + print "not "; + } + print "ok 16\n"; +} + +# Get rid of the temp file +END { unlink "./foo"; } diff --git a/t/lib/strict/vars b/t/lib/strict/vars index 40b5557..f7f8a1c 100644 --- a/t/lib/strict/vars +++ b/t/lib/strict/vars @@ -399,6 +399,20 @@ EXPECT Name "Foo::foo" used only once: possible typo at - line 11. ######## +--FILE-- abc +ok +--FILE-- +# check if our variables are introduced correctly in readline() +package Foo; +use strict 'vars'; +our $FH; +open $FH, "abc" or die "Can't open 'abc': $!"; +print <$FH>; +close $FH; +EXPECT +ok +######## + # Make sure the strict vars failure still occurs # now that the `@i should be written as \@i' failure does not occur # 20000522 mjd@plover.com (MJD) diff --git a/toke.c b/toke.c index af117bc..223cb76 100644 --- a/toke.c +++ b/toke.c @@ -6646,12 +6646,29 @@ S_scan_inputsymbol(pTHX_ char *start) add symbol table ops */ if ((tmp = pad_findmy(d)) != NOT_IN_PAD) { - OP *o = newOP(OP_PADSV, 0); - o->op_targ = tmp; - PL_lex_op = (OP*)newUNOP(OP_READLINE, 0, o); + SV *namesv = AvARRAY(PL_comppad_name)[tmp]; + if (SvFLAGS(namesv) & SVpad_OUR) { + SV *sym = sv_2mortal(newSVpv(HvNAME(GvSTASH(namesv)),0)); + sv_catpvn(sym, "::", 2); + sv_catpv(sym, d+1); + d = SvPVX(sym); + goto intro_sym; + } + else { + OP *o = newOP(OP_PADSV, 0); + o->op_targ = tmp; + PL_lex_op = (OP*)newUNOP(OP_READLINE, 0, o); + } } else { - GV *gv = gv_fetchpv(d+1,TRUE, SVt_PV); + GV *gv; + ++d; +intro_sym: + gv = gv_fetchpv(d, + (PL_in_eval + ? (GV_ADDMULTI | GV_ADDINEVAL) + : TRUE), + SVt_PV); PL_lex_op = (OP*)newUNOP(OP_READLINE, 0, newUNOP(OP_RV2SV, 0, newGVOP(OP_GV, 0, gv)));