diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-04 01:00:49 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-12-04 01:00:49 +0000 |
commit | 2c8ac474a00b933b4d84e8567b4b6db1293ad0ef (patch) | |
tree | e6aae0baa7006e94a6f49152182180b0cd4a5948 /pp.c | |
parent | 951ba7fe8dad4074b389cb34ee7e8b446c17c0fb (diff) | |
download | perl-2c8ac474a00b933b4d84e8567b4b6db1293ad0ef.tar.gz |
better implementation of change#3326; open(local $foo,...) now
allowed in addition to any uninitialized variable, for consistency
with how autovivification works elsewhere; add code to use the
variable name as the name of the handle for simple variables, so
that diagnostics report the handle: "... at - line 1, <$foo> line 10."
p4raw-link: @3326 on //depot/perl: 853846ea710f8feaed8c98b358bdc8967dd522d2
p4raw-id: //depot/perl@4639
Diffstat (limited to 'pp.c')
-rw-r--r-- | pp.c | 29 |
1 files changed, 14 insertions, 15 deletions
@@ -241,26 +241,25 @@ PP(pp_rv2gv) * NI-S 1999/05/07 */ 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 **namep = av_fetch(PL_comppad_name, cUNOP->op_first->op_targ, 4); - if (namep && *namep) { - name = SvPV(*namep,len); - if (!name) { - name = ""; - len = 0; - } - } + char *name; + GV *gv; + if (cUNOP->op_targ) { + STRLEN len; + SV *namesv = PL_curpad[cUNOP->op_targ]; + name = SvPV(namesv, len); + gv = (GV*)NEWSV(0,len); + gv_init(gv, CopSTASH(PL_curcop), name, len, 0); + } + else { + name = CopSTASHPV(PL_curcop); + gv = newGVgen(name); } - gv_init(gv, CopSTASH(PL_curcop), name, len, 0); sv_upgrade(sv, SVt_RV); - SvRV(sv) = (SV *) gv; + SvRV(sv) = (SV*)gv; SvROK_on(sv); SvSETMAGIC(sv); goto wasref; - } + } if (PL_op->op_flags & OPf_REF || PL_op->op_private & HINT_STRICT_REFS) DIE(aTHX_ PL_no_usym, "a symbol"); |