From: Nick Ing-Simmons Date: Sat, 8 May 1999 12:03:45 +0000 (+0000) Subject: Tweaks to open(my $fh,...) stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d8d4d2a360e43d2337420c8e4a3eafc2e301cba;p=p5sagit%2Fp5-mst-13.2.git Tweaks to open(my $fh,...) stuff p4raw-id: //depot/perl@3329 --- diff --git a/op.c b/op.c index 5e2d593..7e3beb2 100644 --- a/op.c +++ b/op.c @@ -4783,17 +4783,24 @@ ck_fun(OP *o) I32 private = 0; /* is this op a FH constructor? */ if (is_handle_constructor(o,numargs)) { + flags = 0; /* Set a flag to tell rv2gv to vivify * need to "prove" flag does not mean something * else already - NI-S 1999/05/07 */ - flags = 0; - private = OPpDEREF; + private = OPpDEREF; +#if 0 + /* Helps with open($array[$n],...) + but is too simplistic - need to do selectively + */ + mod(kid,type); +#endif } kid->op_sibling = 0; kid = newUNOP(OP_RV2GV, flags, scalar(kid)); - if (private) + if (private) { kid->op_private |= private; + } } kid->op_sibling = sibl; *tokid = kid; diff --git a/pp.c b/pp.c index 5a15355..e00b8c0 100644 --- a/pp.c +++ b/pp.c @@ -245,16 +245,19 @@ PP(pp_rv2gv) /* 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); + if (PL_op->op_private & OPpDEREF) { GV *gv = (GV *) newSV(0); + STRLEN len = 0; + char *name = ""; + if (cUNOP->op_first->op_type == OP_PADSV) { + SV *padname = *av_fetch(PL_comppad_name, cUNOP->op_first->op_targ, 4); + name = SvPV(padname,len); + } gv_init(gv, PL_curcop->cop_stash, name, len, 0); sv_upgrade(sv, SVt_RV); SvRV(sv) = (SV *) gv; SvROK_on(sv); + SvSETMAGIC(sv); goto wasref; } if (PL_op->op_flags & OPf_REF || diff --git a/t/io/open.t b/t/io/open.t index 0203f34..50ae38d 100755 --- a/t/io/open.t +++ b/t/io/open.t @@ -4,7 +4,7 @@ $| = 1; $^W = 1; -print "1..8\n"; +print "1..9\n"; # my $file tests