diff options
-rw-r--r-- | pp_sys.c | 14 | ||||
-rw-r--r-- | t/op/select.t | 9 |
2 files changed, 13 insertions, 10 deletions
@@ -1224,24 +1224,20 @@ PP(pp_select) HV *hv; GV * const newdefout = (PL_op->op_private > 0) ? (MUTABLE_GV(POPs)) : NULL; GV * egv = GvEGVx(PL_defoutgv); + GV * const *gvp; if (!egv) egv = PL_defoutgv; hv = isGV_with_GP(egv) ? GvSTASH(egv) : NULL; - if (! hv) - XPUSHs(&PL_sv_undef); - else { - GV * const * const gvp = - HvENAME(hv) + gvp = hv && HvENAME(hv) ? (GV**)hv_fetch(hv, GvNAME(egv), HEK_UTF8(GvNAME_HEK(egv)) ? -GvNAMELEN(egv) : GvNAMELEN(egv), FALSE) : NULL; - if (gvp && *gvp == egv) { + if (gvp && *gvp == egv) { gv_efullname4(TARG, PL_defoutgv, NULL, TRUE); XPUSHTARG; - } - else { + } + else { mXPUSHs(newRV(MUTABLE_SV(egv))); - } } if (newdefout) { diff --git a/t/op/select.t b/t/op/select.t index 06caf1ddfd..1994dd2131 100644 --- a/t/op/select.t +++ b/t/op/select.t @@ -5,7 +5,7 @@ BEGIN { require './test.pl'; } -plan reverse 8; +plan reverse 9; open my $fh, "test.pl" or die "$0 unfortunately cannot open test.pl: $!"; @@ -25,3 +25,10 @@ $stash = \%foo::; *foo:: = *bar::; is select, $handle, 'select returns ref for glob whose stash has been detached'; + +open thwat::snin, "test.pl" or die "$0 is unable to open test.pl: $!"; +select thwat::snin; +$handle = \*thwat::snin; +*thwat:: = *snin::; # gv is now *__ANON__::snin +is select, $handle, + 'select returns ref for glob with no stash pointer'; |