This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
avoid typeglob persistence in pp_readline()
authorGurusamy Sarathy <gsar@cpan.org>
Tue, 23 Mar 1999 00:56:38 +0000 (00:56 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Tue, 23 Mar 1999 00:56:38 +0000 (00:56 +0000)
p4raw-id: //depot/perl@3125

sv.c
t/op/gv.t

diff --git a/sv.c b/sv.c
index 4014204..350b053 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -3176,7 +3176,13 @@ sv_gets(register SV *sv, register PerlIO *fp, I32 append)
     I32 i;
 
     SV_CHECK_THINKFIRST(sv);
-    (void)SvUPGRADE(sv, SVt_PV);
+    if (SvTYPE(sv) >= SVt_PV) {
+       if (SvFAKE(sv) && SvTYPE(sv) == SVt_PVGV)
+           sv_unglob(sv);
+    }
+    else
+       sv_upgrade(sv, SVt_PV);
+
     SvSCREAM_off(sv);
 
     if (RsSNARF(PL_rs)) {
index df4984e..10d84ee 100755 (executable)
--- a/t/op/gv.t
+++ b/t/op/gv.t
@@ -4,7 +4,7 @@
 # various typeglob tests
 #
 
-print "1..29\n";
+print "1..30\n";
 
 # type coersion on assignment
 $foo = 'foo';
@@ -121,3 +121,13 @@ print {*x{FILEHANDLE}} "ok 23\n";
     ++$test; &{$a};
 }
 
+# does pp_readline() handle glob-ness correctly?
+
+{
+    my $g = *foo;
+    $g = <DATA>;
+    print $g;
+}
+
+__END__
+ok 30