Change 12561 by jhi@alpha on 2001/10/22 12:00:23

        Integrate changes #12549 and #12550 from maintperl;
        
        readline() doesn't work with our variables; it confuses them with
        my variables (change#4227 was incomplete)

Affected files ...

... //depot/perl/t/base/rs.t#8 integrate
... //depot/perl/t/lib/strict/vars#2 edit
... //depot/perl/toke.c#389 integrate

Differences ...

==== //depot/perl/t/base/rs.t#8 (xtext) ====
Index: perl/t/base/rs.t
--- perl/t/base/rs.t.~1~        Mon Oct 22 06:15:05 2001
+++ perl/t/base/rs.t    Mon Oct 22 06:15:05 2001
@@ -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 @@
 $bar = <TESTFILE>;
 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 @@
   # 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"; }

==== //depot/perl/t/lib/strict/vars#2 (text) ====
Index: perl/t/lib/strict/vars
--- perl/t/lib/strict/vars.~1~  Mon Oct 22 06:15:05 2001
+++ perl/t/lib/strict/vars      Mon Oct 22 06:15:05 2001
@@ -399,6 +399,20 @@
 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 [EMAIL PROTECTED] (MJD)

==== //depot/perl/toke.c#389 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~     Mon Oct 22 06:15:05 2001
+++ perl/toke.c Mon Oct 22 06:15:05 2001
@@ -6646,12 +6646,29 @@
               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)));
End of Patch.

Reply via email to