This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_leavewrite wasn't warning for unopened handles unless 'closed' was enabled.
authorNicholas Clark <nick@ccl4.org>
Thu, 30 Dec 2010 16:52:22 +0000 (16:52 +0000)
committerNicholas Clark <nick@ccl4.org>
Thu, 30 Dec 2010 16:52:22 +0000 (16:52 +0000)
It was checking that category 'closed' was enabled for warnings before calling
report_evil_fh(), which in turn was (correctly) checking category 'unopened'.

pp_sys.c
t/lib/warnings/pp_sys

index 2845266..23cdd5b 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1449,7 +1449,7 @@ PP(pp_leavewrite)
     if (!fp) {
        if (IoIFP(io))
            report_wrongway_fh(gv, '<');
-       else if (ckWARN(WARN_CLOSED))
+       else
            report_evil_fh(gv);
        PUSHs(&PL_sv_no);
     }
index 8c61397..62e47c1 100644 (file)
@@ -131,20 +131,57 @@ Filehandle STDIN opened only for input at - line 5.
 use warnings 'closed' ;
 format STDIN =
 .
+format FOO =
+.
 close STDIN;
 write STDIN;
+write FOO;
 opendir STDIN, ".";
 write STDIN;
 closedir STDIN;
+opendir FOO, ".";
+write FOO;
+closedir FOO;
 no warnings 'closed' ;
 write STDIN;
+write FOO;
 opendir STDIN, ".";
+opendir FOO, ".";
 write STDIN;
+write FOO;
 EXPECT
-write() on closed filehandle STDIN at - line 6.
 write() on closed filehandle STDIN at - line 8.
+write() on closed filehandle STDIN at - line 11.
        (Are you trying to call write() on dirhandle STDIN?)
 ########
+########
+# pp_sys.c [pp_leavewrite]
+use warnings 'unopened';
+format STDIN =
+.
+format FOO =
+.
+close STDIN;
+write STDIN;
+write FOO;
+opendir STDIN, ".";
+write STDIN;
+closedir STDIN;
+opendir FOO, ".";
+write FOO;
+closedir FOO;
+no warnings 'unopened';
+write STDIN;
+write FOO;
+opendir STDIN, ".";
+opendir FOO, ".";
+write STDIN;
+write FOO;
+EXPECT
+write() on unopened filehandle FOO at - line 10.
+write() on unopened filehandle FOO at - line 15.
+       (Are you trying to call write() on dirhandle FOO?)
+########
 # pp_sys.c [pp_leavewrite]
 use warnings 'io' ;
 format STDOUT_TOP =