summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2000-08-04 04:06:30 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2000-08-04 04:06:30 +0000
commit9ddeeac95cc2728719c7399fdde362518bb522a0 (patch)
treed29ddcd441d66850812e030b60e6b2964f47d4c3
parent4ec0190b08c455a89a958545841a796e66051771 (diff)
downloadperl-9ddeeac95cc2728719c7399fdde362518bb522a0.tar.gz
In the warnings call filehandles consistently so;
add "unopened" warning for stat(). p4raw-id: //depot/perl@6519
-rw-r--r--doio.c12
-rw-r--r--pod/perldiag.pod18
-rw-r--r--pp_sys.c10
-rw-r--r--t/pragma/warn/doio23
-rw-r--r--t/pragma/warn/pp_sys8
5 files changed, 41 insertions, 30 deletions
diff --git a/doio.c b/doio.c
index 7d52d6ff9c..defe006004 100644
--- a/doio.c
+++ b/doio.c
@@ -812,7 +812,7 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit)
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;
@@ -926,7 +926,7 @@ Perl_do_tell(pTHX_ GV *gv)
{
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;
@@ -948,7 +948,7 @@ Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence)
{
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;
@@ -965,7 +965,7 @@ Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence)
{
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;
@@ -1196,8 +1196,8 @@ Perl_my_stat(pTHX)
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);
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index d6bf043a78..d2576bc711 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1064,7 +1064,7 @@ not realizing that 777 will be interpreted as a decimal number,
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.
@@ -2247,6 +2247,11 @@ pointing outside the buffer. This is difficult to imagine. The sole
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.
@@ -2815,7 +2820,7 @@ or setgid bit set. This doesn't make much sense.
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.
@@ -2990,7 +2995,7 @@ unless there was a failure. You probably wanted to use system()
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
@@ -3105,16 +3110,11 @@ before now. Check your logic flow.
(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
diff --git a/pp_sys.c b/pp_sys.c
index aa6d0bd536..9a264c8c44 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2505,8 +2505,12 @@ PP(pp_stat)
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;
@@ -3059,8 +3063,8 @@ PP(pp_fttext)
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;
diff --git a/t/pragma/warn/doio b/t/pragma/warn/doio
index 813f149fb5..00371031a4 100644
--- a/t/pragma/warn/doio
+++ b/t/pragma/warn/doio
@@ -12,22 +12,22 @@
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]
@@ -96,7 +96,7 @@ close "fred" ;
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' ;
@@ -105,17 +105,20 @@ tell(STDIN);
$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' ;
diff --git a/t/pragma/warn/pp_sys b/t/pragma/warn/pp_sys
index ad5982ab81..1666b6a143 100644
--- a/t/pragma/warn/pp_sys
+++ b/t/pragma/warn/pp_sys
@@ -74,7 +74,8 @@
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]
@@ -328,10 +329,13 @@ Unsuccessful stat on filename containing newline at - line 3.
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' ;