summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-14 00:33:15 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-14 00:51:58 -0800
commit8080e3c81732aa2a08a2191391ba00b29588ab46 (patch)
tree49c79f62c983c3cac41f711c73a536cb21c14681 /pp_sys.c
parent2ad48547234bdf521daff432b65a0b173efd2a19 (diff)
downloadperl-8080e3c81732aa2a08a2191391ba00b29588ab46.tar.gz
Don’t emit unopened warning for other stat(HANDLE) error
-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. :-)
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 77677647c1..88e2f4e298 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;
}
}