Improve rcatline bad fh warnings
authorFather Chrysostomos <sprout@cpan.org>
Mon, 30 Dec 2013 01:11:24 +0000 (17:11 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 30 Dec 2013 01:11:24 +0000 (17:11 -0800)
This is not helpful:

append I/O operator() on closed filehandle STDIN at - line 3.
append I/O operator() on closed filehandle STDIN at - line 4.
(Are you trying to call append I/O operator() on dirhandle STDIN?)

That .=<> compiles to a separate op from <> is an implementation
detail, so show ‘readline()’ as we do with <>.

t/lib/warnings/pp_hot
util.c

index ad63d2a..4e63073 100644 (file)
@@ -210,6 +210,19 @@ readline() on closed filehandle STDIN at - line 4.
        (Are you trying to call readline() on dirhandle STDIN?)
 ########
 # pp_hot.c [Perl_do_readline]
+use warnings 'closed' ;
+close STDIN        ; $a .= <STDIN> ;
+opendir STDIN, "." ; $a .= <STDIN> ;
+closedir STDIN;
+no warnings 'closed' ;
+opendir STDIN, "." ; $a .= <STDIN> ;
+$a = <STDIN> ;
+EXPECT
+readline() on closed filehandle STDIN at - line 3.
+readline() on closed filehandle STDIN at - line 4.
+       (Are you trying to call readline() on dirhandle STDIN?)
+########
+# pp_hot.c [Perl_do_readline]
 use warnings 'io' ;
 my $file = "./xcv" ; unlink $file ;
 open (FH, ">$file") or die $! ;
diff --git a/util.c b/util.c
index 55fc941..596955b 100644 (file)
--- a/util.c
+++ b/util.c
@@ -3403,7 +3403,8 @@ Perl_report_evil_fh(pTHX_ const GV *gv)
            (const char *)(OP_IS_FILETEST(op) ? "" : "()");
        const char * const func =
            (const char *)
-           (op == OP_READLINE   ? "readline"  :        /* "<HANDLE>" not nice */
+           (op == OP_READLINE || op == OP_RCATLINE
+                                ? "readline"  :        /* "<HANDLE>" not nice */
             op == OP_LEAVEWRITE ? "write" :            /* "write exit" not nice */
             PL_op_desc[op]);
        const char * const type =