add "unopened" warning for stat().
p4raw-id: //depot/perl@6519
dTHR;
if (ckWARN(WARN_UNOPENED))
Perl_warner(aTHX_ WARN_UNOPENED,
- "Close on unopened file %s",GvENAME(gv));
+ "close() on unopened filehandle %s",GvENAME(gv));
SETERRNO(EBADF,SS$_IVCHAN);
}
return FALSE;
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- Perl_warner(aTHX_ WARN_UNOPENED, "tell() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "tell() on unopened filehandle");
}
SETERRNO(EBADF,RMS$_IFI);
return (Off_t)-1;
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- Perl_warner(aTHX_ WARN_UNOPENED, "seek() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "seek() on unopened filehandle");
}
SETERRNO(EBADF,RMS$_IFI);
return FALSE;
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- Perl_warner(aTHX_ WARN_UNOPENED, "sysseek() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "sysseek() on unopened filehandle");
}
SETERRNO(EBADF,RMS$_IFI);
return (Off_t)-1;
if (tmpgv == PL_defgv)
return PL_laststatval;
if (ckWARN(WARN_UNOPENED))
- Perl_warner(aTHX_ WARN_UNOPENED, "Stat on unopened file %s",
- GvENAME(tmpgv));
+ Perl_warner(aTHX_ WARN_UNOPENED, "%s on unopened filehandle %s",
+ PL_op_desc[PL_op->op_type], GvENAME(tmpgv));
PL_statgv = Nullgv;
sv_setpv(PL_statname,"");
return (PL_laststatval = -1);
equivalent to 01411. Octal constants are introduced with a leading 0 in
Perl, as in C.
-=item Close on unopened file %s
+=item close() on unopened filehandle %s
(W unopened) You tried to close a filehandle that was never opened.
exception to this is that C<sysread()>ing past the buffer will extend
the buffer and zero pad the new area.
+=item -%s on unopened filehandle %s
+
+(W unopened) You tried to invoke a file test operator on a filehandle
+that isn't open. Check your logic. See also L<perlfunc/-X>.
+
=item oops: oopsAV
(S internal) An internal warning that the grammar is screwed up.
construct. Remember that bracketing delimiters count nesting level.
Missing the leading C<$> from a variable C<$m> may cause this error.
-=item %sseek() on unopened file
+=item %sseek() on unopened filehandle
(W unopened) You tried to use the seek() or sysseek() function on a
filehandle that was either never opened or has since been closed.
instead, which does return. To suppress this warning, put the exec() in
a block by itself.
-=item Stat on unopened file %s
+=item stat() on unopened filehandle %s
(W unopened) You tried to use the stat() function (or an equivalent file
test) on a filehandle that was either never opened or has since been
(F) You tried to use C<goto> to reach a label that was too deeply nested
for Perl to reach. Perl is doing you a favor by refusing.
-=item tell() on unopened file
+=item tell() on unopened filehandle
(W unopened) You tried to use the tell() function on a filehandle that
was either never opened or has since been closed.
-=item Test on unopened file %s
-
-(W unopened) You tried to invoke a file test operator on a filehandle
-that isn't open. Check your logic. See also L<perlfunc/-X>.
-
=item That use of $[ is unsupported
(F) Assignment to C<$[> is now strictly circumscribed, and interpreted
PL_laststatval = (GvIO(tmpgv) && IoIFP(GvIOp(tmpgv))
? PerlLIO_fstat(PerlIO_fileno(IoIFP(GvIOn(tmpgv))), &PL_statcache) : -1);
}
- if (PL_laststatval < 0)
+ if (PL_laststatval < 0) {
+ if (ckWARN(WARN_UNOPENED))
+ Perl_warner(aTHX_ WARN_UNOPENED, "%s() on unopened filehandle %s",
+ PL_op_desc[PL_op->op_type], GvENAME(tmpgv));
max = 0;
+ }
}
else {
SV* sv = POPs;
else {
if (ckWARN(WARN_UNOPENED)) {
gv = cGVOP_gv;
- Perl_warner(aTHX_ WARN_UNOPENED, "Test on unopened file %s",
- GvENAME(gv));
+ Perl_warner(aTHX_ WARN_UNOPENED, "%s on unopened filehandle %s",
+ PL_op_desc[PL_op->op_type], GvENAME(gv));
}
SETERRNO(EBADF,RMS$_IFI);
RETPUSHUNDEF;
warn(warn_nl, "open"); [Perl_do_open9]
open(F, "true\ncd")
- Close on unopened file %s [Perl_do_close] <<TODO
+ close() on unopened filehandle %s [Perl_do_close] <<TODO
$a = "fred";close("$a")
- tell() on unopened file [Perl_do_tell]
+ tell() on unopened filehandle [Perl_do_tell]
$a = "fred";$a = tell($a)
- seek() on unopened file [Perl_do_seek]
+ seek() on unopened filehandle [Perl_do_seek]
$a = "fred";$a = seek($a,1,1)
- sysseek() on unopened file [Perl_do_sysseek]
+ sysseek() on unopened filehandle [Perl_do_sysseek]
$a = "fred";$a = seek($a,1,1)
warn(warn_uninit); [Perl_do_print]
print $a ;
- Stat on unopened file <%s> [Perl_my_stat]
+ -x on unopened filehandle %s [Perl_my_stat]
close STDIN ; -x STDIN ;
warn(warn_nl, "stat"); [Perl_my_stat]
no warnings 'unopened' ;
close "joe" ;
EXPECT
-Close on unopened file fred at - line 3.
+close() on unopened filehandle fred at - line 3.
########
# doio.c [Perl_do_tell Perl_do_seek Perl_do_sysseek Perl_my_stat]
use warnings 'io' ;
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
+stat(STDIN) ;
no warnings 'io' ;
close STDIN ;
tell(STDIN);
$a = seek(STDIN,1,1);
$a = sysseek(STDIN,1,1);
-x STDIN ;
+stat(STDIN) ;
EXPECT
-tell() on unopened file at - line 4.
-seek() on unopened file at - line 5.
-sysseek() on unopened file at - line 6.
-Stat on unopened file STDIN at - line 7.
+tell() on unopened filehandle at - line 4.
+seek() on unopened filehandle at - line 5.
+sysseek() on unopened filehandle at - line 6.
+-x on unopened filehandle STDIN at - line 7.
+stat() on unopened filehandle STDIN at - line 8.
########
# doio.c [Perl_do_print]
use warnings 'uninitialized' ;
warn(warn_nl, "stat"); [pp_stat]
- Test on unopened file <%s>
+ -T on unopened filehandle %s
+ stat() on unopened filehandle %s
close STDIN ; -T STDIN ;
warn(warn_nl, "open"); [pp_fttext]
use warnings 'unopened' ;
close STDIN ;
-T STDIN ;
+stat(STDIN) ;
no warnings 'unopened' ;
-T STDIN ;
+stat(STDIN);
EXPECT
-Test on unopened file STDIN at - line 4.
+-T on unopened filehandle STDIN at - line 4.
+stat() on unopened filehandle STDIN at - line 5.
########
# pp_sys.c [pp_fttext]
use warnings 'newline' ;