From d955f84cfebcbed74088977f0bc7b1162c00a426 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sun, 29 Dec 2013 17:11:24 -0800 Subject: [PATCH] Improve rcatline bad fh warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 13 +++++++++++++ util.c | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/t/lib/warnings/pp_hot b/t/lib/warnings/pp_hot index ad63d2a..4e63073 100644 --- a/t/lib/warnings/pp_hot +++ b/t/lib/warnings/pp_hot @@ -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 .= ; +opendir STDIN, "." ; $a .= ; +closedir STDIN; +no warnings 'closed' ; +opendir STDIN, "." ; $a .= ; +$a = ; +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 --- 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" : /* "" not nice */ + (op == OP_READLINE || op == OP_RCATLINE + ? "readline" : /* "" not nice */ op == OP_LEAVEWRITE ? "write" : /* "write exit" not nice */ PL_op_desc[op]); const char * const type = -- 2.7.4