From: Steve Peters Date: Fri, 28 Jul 2006 00:42:04 +0000 (+0000) Subject: Change stat() and -X filetests so that they treat *FILE{IO} X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ad02613cb6d8974aab9c68839c06129c8510c983;p=p5sagit%2Fp5-mst-13.2.git Change stat() and -X filetests so that they treat *FILE{IO} filehandles like *FILE filehandles. This resolves RT #8244. p4raw-id: //depot/perl@28628 --- diff --git a/doio.c b/doio.c index 585eb54..399cadf 100644 --- a/doio.c +++ b/doio.c @@ -1276,6 +1276,7 @@ Perl_my_stat(pTHX) if (gv == PL_defgv) return PL_laststatval; io = GvIO(gv); + do_fstat_have_io: PL_laststype = OP_STAT; PL_statgv = gv; sv_setpvn(PL_statname, "", 0); @@ -1316,6 +1317,10 @@ Perl_my_stat(pTHX) gv = (GV*)SvRV(sv); goto do_fstat; } + else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) { + io = (IO*)SvRV(sv); + goto do_fstat_have_io; + } s = SvPV_const(sv, len); PL_statgv = NULL; diff --git a/pp_sys.c b/pp_sys.c index 4246e3c..4465988 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2781,6 +2781,7 @@ PP(pp_stat) dVAR; dSP; GV *gv; + IO *io; I32 gimme; I32 max = 13; @@ -2802,7 +2803,8 @@ PP(pp_stat) PL_statgv = gv; sv_setpvn(PL_statname, "", 0); if(gv) { - IO* const io = GvIO(gv); + io = GvIO(gv); + do_fstat_have_io: if (io) { if (IoIFP(io)) { PL_laststatval = @@ -2832,13 +2834,18 @@ PP(pp_stat) if (SvTYPE(sv) == SVt_PVGV) { gv = (GV*)sv; goto do_fstat; - } - else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) { - gv = (GV*)SvRV(sv); - if (PL_op->op_type == OP_LSTAT) - goto do_fstat_warning_check; - goto do_fstat; - } + } else if(SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVGV) { + gv = (GV*)SvRV(sv); + if (PL_op->op_type == OP_LSTAT) + goto do_fstat_warning_check; + goto do_fstat; + } else if (SvROK(sv) && SvTYPE(SvRV(sv)) == SVt_PVIO) { + io = (IO*)SvRV(sv); + if (PL_op->op_type == OP_LSTAT) + goto do_fstat_warning_check; + goto do_fstat_have_io; + } + sv_setpv(PL_statname, SvPV_nolen_const(sv)); PL_statgv = NULL; PL_laststype = PL_op->op_type;