From 8080e3c81732aa2a08a2191391ba00b29588ab46 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 14 Jan 2012 00:33:15 -0800 Subject: [PATCH] =?utf8?q?Don=E2=80=99t=20emit=20unopened=20warning=20for?= =?utf8?q?=20other=20stat(HANDLE)=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit -r or -T on a GV with no IO or on an IO with no fp (or dirp for -r) will produce an ‘unopened’ warning. stat() on a filehandle will warn about an unopened filehandle not only if there is no fp, but also if the fstat call fails (with errno containing EBADP, EFAULT or EIO, at least on Darwin). I don’t know if there is a way to test this. (But pp_stat and my_stat_flags are getting closer, so this must be correct. :-) --- pp_sys.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pp_sys.c b/pp_sys.c index 7767764..88e2f4e 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2759,6 +2759,7 @@ PP(pp_stat) if (PL_op->op_flags & OPf_REF ? (gv = cGVOP_gv, 1) : !!(sv=POPs, gv = MAYBE_DEREF_GV(sv))) { + bool havefp = FALSE; if (PL_op->op_type == OP_LSTAT) { if (gv != PL_defgv) { do_fstat_warning_check: @@ -2784,9 +2785,11 @@ PP(pp_stat) if (IoIFP(io)) { PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache); + havefp = TRUE; } else if (IoDIRP(io)) { PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache); + havefp = TRUE; } else { PL_laststatval = -1; } @@ -2795,7 +2798,7 @@ PP(pp_stat) } if (PL_laststatval < 0) { - report_evil_fh(gv); + if (!havefp) report_evil_fh(gv); max = 0; } } -- 2.7.4