diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-09 10:40:31 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2003-04-09 10:40:31 +0000 |
commit | 0c4b0a3f6df5172b70e3383e7419936faa3fc0a0 (patch) | |
tree | 187c7ae5fb1531eac2d9546c326c99cbc5c9783e /op.c | |
parent | 294d099eb0fb837b82ab70fe7f81a0b70a4fa5c9 (diff) | |
download | perl-0c4b0a3f6df5172b70e3383e7419936faa3fc0a0.tar.gz |
Try to be more descriptive than just __ANONIO__ which is what
you get when you autovivify filehandles into array/hash elements.
p4raw-id: //depot/perl@19172
Diffstat (limited to 'op.c')
-rw-r--r-- | op.c | 48 |
1 files changed, 45 insertions, 3 deletions
@@ -5108,9 +5108,51 @@ Perl_ck_fun(pTHX_ OP *o) else if (kid->op_type == OP_AELEM || kid->op_type == OP_HELEM) { - name = "__ANONIO__"; - len = 10; - mod(kid,type); + OP *op; + + name = 0; + if ((op = ((BINOP*)kid)->op_first)) { + SV *tmpstr = Nullsv; + char *a = + kid->op_type == OP_AELEM ? + "[]" : "{}"; + if (((op->op_type == OP_RV2AV) || + (op->op_type == OP_RV2HV)) && + (op = ((UNOP*)op)->op_first) && + (op->op_type == OP_GV)) { + /* packagevar $a[] or $h{} */ + GV *gv = cGVOPx_gv(op); + if (gv) + tmpstr = + Perl_newSVpvf(aTHX_ + "%s%c...%c", + GvNAME(gv), + a[0], a[1]); + } + else if (op->op_type == OP_PADAV + || op->op_type == OP_PADHV) { + /* lexicalvar $a[] or $h{} */ + char *padname = + PAD_COMPNAME_PV(op->op_targ); + if (padname) + tmpstr = + Perl_newSVpvf(aTHX_ + "%s%c...%c", + padname + 1, + a[0], a[1]); + + } + if (tmpstr) { + name = savepv(SvPVX(tmpstr)); + len = strlen(name); + sv_2mortal(tmpstr); + } + } + if (!name) { + name = "__ANONIO__"; + len = 10; + } + mod(kid, type); } if (name) { SV *namesv; |