diff options
author | Nick Ing-Simmons <nik@tiuk.ti.com> | 1999-05-07 21:24:50 +0000 |
---|---|---|
committer | Nick Ing-Simmons <nik@tiuk.ti.com> | 1999-05-07 21:24:50 +0000 |
commit | 853846ea710f8feaed8c98b358bdc8967dd522d2 (patch) | |
tree | b897c99fba920636ba7e2d962c8cf67880fd40d6 /pp.c | |
parent | 7c1e0849686a4ea069f6fa2a095a70c337e62ace (diff) | |
download | perl-853846ea710f8feaed8c98b358bdc8967dd522d2.tar.gz |
Implement open( my $fh, ...) and similar.
Set flag in op.c for "constructor ops"
In pp_rv2gv, if flag is set and arg is PADSV and uninit
vivify as reference to a detached GV.
(Name of GV is the pad name.)
This scheme should "just work" for pipe/socket etc. too.
#if 0 out the open(FH,undef) for now.
Change t/io/open.t to test open(my $fh,...)
p4raw-id: //depot/perl@3326
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 22 |
1 files changed, 21 insertions, 1 deletions
@@ -214,7 +214,7 @@ PP(pp_padany) PP(pp_rv2gv) { - djSP; dTOPss; + djSP; dTOPss; if (SvROK(sv)) { wasref: @@ -242,6 +242,21 @@ PP(pp_rv2gv) goto wasref; } if (!SvOK(sv)) { + /* If this is a 'my' scalar and flag is set then vivify + * NI-S 1999/05/07 + */ + if ( (PL_op->op_private & OPpDEREF) && + cUNOP->op_first->op_type == OP_PADSV ) { + STRLEN len; + SV *padname = *av_fetch(PL_comppad_name, cUNOP->op_first->op_targ, 4); + char *name = SvPV(padname,len); + GV *gv = (GV *) newSV(0); + gv_init(gv, PL_curcop->cop_stash, name, len, 0); + sv_upgrade(sv, SVt_RV); + SvRV(sv) = (SV *) gv; + SvROK_on(sv); + goto wasref; + } if (PL_op->op_flags & OPf_REF || PL_op->op_private & HINT_STRICT_REFS) DIE(PL_no_usym, "a symbol"); @@ -1016,8 +1031,13 @@ PP(pp_modulo) #endif /* Backward-compatibility clause: */ +#if 0 dright = trunc(dright + 0.5); dleft = trunc(dleft + 0.5); +#else + dright = floor(dright + 0.5); + dleft = floor(dleft + 0.5); +#endif if (!dright) DIE("Illegal modulus zero"); |