From: Rafael Garcia-Suarez Date: Sat, 23 Dec 2006 11:45:28 +0000 (+0000) Subject: syswrite() wasn't reporting a warning when writing to a filehandle X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cf16741603085845f81fd648e5e3d2673dbdf560;p=p5sagit%2Fp5-mst-13.2.git syswrite() wasn't reporting a warning when writing to a filehandle opened only for input. p4raw-id: //depot/perl@29614 --- diff --git a/pp_sys.c b/pp_sys.c index 6754c3e..53bffee 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1829,10 +1829,14 @@ PP(pp_send) SETERRNO(0,0); io = GvIO(gv); - if (!io || !IoIFP(io)) { + if (!io || !IoIFP(io) || IoTYPE(io) == IoTYPE_RDONLY) { retval = -1; - if (ckWARN(WARN_CLOSED)) - report_evil_fh(gv, io, PL_op->op_type); + if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) { + if (io && IoIFP(io)) + report_evil_fh(gv, io, OP_phoney_INPUT_ONLY); + else + report_evil_fh(gv, io, PL_op->op_type); + } SETERRNO(EBADF,RMS_IFI); goto say_undef; } diff --git a/t/lib/warnings/pp_sys b/t/lib/warnings/pp_sys index 173d0d8..0dd3efe 100644 --- a/t/lib/warnings/pp_sys +++ b/t/lib/warnings/pp_sys @@ -197,6 +197,14 @@ EXPECT Filehandle STDIN opened only for input at - line 3. ######## # pp_sys.c [pp_send] +use warnings 'io' ; +syswrite STDIN, "fred"; +no warnings 'io' ; +syswrite STDIN, "fred"; +EXPECT +Filehandle STDIN opened only for input at - line 3. +######## +# pp_sys.c [pp_send] use warnings 'closed' ; close STDIN; syswrite STDIN, "fred", 1;