From: Jarkko Hietaniemi Date: Wed, 26 Jul 2000 17:53:31 +0000 (+0000) Subject: Fix *foo{FORMAT}. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f4d13ee9d0b78f23038694a8d4237f00da3ad10c;p=p5sagit%2Fp5-mst-13.2.git Fix *foo{FORMAT}. From: "H.Merijn Brand" Subject: Re: Looking for a starting point (Mark-Jason?, Chip?, Jarkko?) Date: Wed, 26 Jul 2000 19:51:02 +0200 Message-Id: <20000726194952.41DD.H.M.BRAND@hccnet.nl> From: Graham Barr Subject: Re: Looking for a starting point (Mark-Jason?, Chip?, Jarkko?) Date: Wed, 26 Jul 2000 17:38:36 +0100 Message-ID: <20000726173836.L472@pobox.com> p4raw-id: //depot/perl@6445 --- diff --git a/pp.c b/pp.c index cb55181..988619f 100644 --- a/pp.c +++ b/pp.c @@ -599,6 +599,9 @@ PP(pp_gelem) case 'F': if (strEQ(elem, "FILEHANDLE")) /* XXX deprecate in 5.005 */ tmpRef = (SV*)GvIOp(gv); + else + if (strEQ(elem, "FORMAT")) + tmpRef = (SV*)GvFORM(gv); break; case 'G': if (strEQ(elem, "GLOB")) diff --git a/sv.c b/sv.c index 60db718..e248d14 100644 --- a/sv.c +++ b/sv.c @@ -2831,6 +2831,13 @@ Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr) dref = (SV*)GvIOp(dstr); GvIOp(dstr) = (IO*)sref; break; + case SVt_PVFM: + if (intro) + SAVESPTR(GvFORM(dstr)); + else + dref = (SV*)GvFORM(dstr); + GvFORM(dstr) = (CV*)sref; + break; default: if (intro) SAVESPTR(GvSV(dstr)); diff --git a/t/op/gv.t b/t/op/gv.t index 209f5eb..bb10b75 100755 --- a/t/op/gv.t +++ b/t/op/gv.t @@ -11,7 +11,7 @@ BEGIN { use warnings; -print "1..40\n"; +print "1..41\n"; # type coersion on assignment $foo = 'foo'; @@ -97,15 +97,19 @@ $x = "ok 17\n"; %x = ("ok 19" => "\n"); sub x { "ok 20\n" } print ${*x{SCALAR}}, @{*x{ARRAY}}, %{*x{HASH}}, &{*x{CODE}}; +format x = +ok 21 +. +print ref *x{FORMAT} eq "FORMAT" ? "ok 21\n" : "not ok 21\n"; *x = *STDOUT; -print *{*x{GLOB}} eq "*main::STDOUT" ? "ok 21\n" : "not ok 21\n"; -print {*x{IO}} "ok 22\n"; -print {*x{FILEHANDLE}} "ok 23\n"; +print *{*x{GLOB}} eq "*main::STDOUT" ? "ok 22\n" : "not ok 22\n"; +print {*x{IO}} "ok 23\n"; +print {*x{FILEHANDLE}} "ok 24\n"; # test if defined() doesn't create any new symbols { - my $test = 23; + my $test = 24; my $a = "SYM000"; print "not " if defined *{$a}; @@ -131,7 +135,7 @@ print {*x{FILEHANDLE}} "ok 23\n"; # although it *should* if you're talking about magicals { - my $test = 29; + my $test = 30; my $a = "]"; print "not " unless defined ${$a}; @@ -173,4 +177,4 @@ print {*x{FILEHANDLE}} "ok 23\n"; } __END__ -ok 40 +ok 41