diff options
author | Father Chrysostomos <sprout@cpan.org> | 2012-01-14 00:33:15 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-01-14 00:51:58 -0800 |
commit | 8080e3c81732aa2a08a2191391ba00b29588ab46 (patch) | |
tree | 49c79f62c983c3cac41f711c73a536cb21c14681 /pp_sys.c | |
parent | 2ad48547234bdf521daff432b65a0b173efd2a19 (diff) | |
download | perl-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.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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; } } |