From: Rafael Garcia-Suarez Date: Wed, 25 Sep 2002 21:58:12 +0000 (+0200) Subject: Re: perlio bug? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=97828cef4d4cd22b548b8ec430d2e0e28ea8ae8c;p=p5sagit%2Fp5-mst-13.2.git Re: perlio bug? Message-Id: <20020925215812.3b7adb0d.rgarciasuarez@free.fr> p4raw-id: //depot/perl@17954 --- diff --git a/doio.c b/doio.c index a706fbf..fdd83f6 100644 --- a/doio.c +++ b/doio.c @@ -536,12 +536,14 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, if ((IoTYPE(io) == IoTYPE_RDONLY) && (fp == PerlIO_stdout() || fp == PerlIO_stderr())) { Perl_warner(aTHX_ packWARN(WARN_IO), - "Filehandle STD%s opened only for input", - (fp == PerlIO_stdout()) ? "OUT" : "ERR"); + "Filehandle STD%s reopened as %s only for input", + ((fp == PerlIO_stdout()) ? "OUT" : "ERR"), + GvENAME(gv)); } else if ((IoTYPE(io) == IoTYPE_WRONLY) && fp == PerlIO_stdin()) { Perl_warner(aTHX_ packWARN(WARN_IO), - "Filehandle STDIN opened only for output"); + "Filehandle STDIN reopened as %s only for output", + GvENAME(gv)); } } diff --git a/pod/perldiag.pod b/pod/perldiag.pod index a0ef21a..a08837d 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1485,12 +1485,6 @@ PDP-11 or something? to be a read-write filehandle, you needed to open it with "+<" or "+>" or "+>>" instead of with "<" or nothing. If you intended only to write the file, use ">" or ">>". See L. -The warning will also occur if STDOUT (file descriptor 1) or STDERR -(file descriptor 2) is opened for input, this is a pre-emptive warning in -case some other part of your program or a child process is expecting STDOUT -and STDERR to be writable. This can happen accidentally if you -C or STDERR and then C an unrelated handle which -will resuse the lowest numbered available descriptor. =item Filehandle %s opened only for output @@ -1498,12 +1492,17 @@ will resuse the lowest numbered available descriptor. If you intended it to be a read/write filehandle, you needed to open it with "+<" or "+>" or "+>>" instead of with "<" or nothing. If you intended only to read from the file, use "<". See L. -The warning will also occur if STDIN (file descriptor 0) is opened -for output - this is a pre-emptive warning in case some other part of your -program or a child process is expecting STDIN to be readable. -This can happen accidentally if you C and then C an -unrelated handle which will resuse the lowest numbered available -descriptor. + +=item Filehandle %s reopened as %s only for input + +(W io) You opened for reading a filehandle that got the same filehandle id +as STDOUT or STDERR. This occured because you closed STDOUT or STDERR +previously. + +=item Filehandle STDIN reopened as %s only for output + +(W io) You opened for writing a filehandle that got the same filehandle id +as STDIN. This occured because you closed STDIN previously. =item Final $ should be \$ or $name diff --git a/t/lib/warnings/doio b/t/lib/warnings/doio index bb09aa8..15d4c5e 100644 --- a/t/lib/warnings/doio +++ b/t/lib/warnings/doio @@ -275,3 +275,42 @@ no warnings 'io'; open FOO, '>', \$x; EXPECT Can't open a reference at - line 14. +######## +# doio.c [Perl_do_openn] +use Config; +BEGIN { + if (!$Config{useperlio}) { + print <doiowarn.tmp"; close $fh1; +no warnings 'io' ; +open my $fh2, ">doiowarn.tmp"; close $fh2; +unlink "doiowarn.tmp"; +EXPECT +Filehandle STDIN reopened as $fh1 only for output at - line 14.