From: Todd C. Miller Date: Fri, 21 Apr 2000 10:43:46 +0000 (-0600) Subject: Warn under -w if lstat(FH) is attempted. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9d8379451873878ac81deb50e7500757d4f8bc16;p=p5sagit%2Fp5-mst-13.2.git Warn under -w if lstat(FH) is attempted. Subject: [ID 20000421.003] perlfunc says you can lstat a file handle but you cannot Message-Id: <200004211643.e3LGhkX24720@xerxes.courtesan.com> p4raw-id: //depot/perl@6524 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 930b9de..cf6cd19 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1767,6 +1767,12 @@ effective uids or gids failed. to check the return value of your socket() call? See L. +=item lstat() on filehandle %s + +(W io) You tried to do a lstat on a filehandle. What did you mean +by that? lstat() makes sense only on filenames. (Perl did a fstat() +instead on the filehandle.) + =item Lvalue subs returning %s not implemented yet (F) Due to limitations in the current implementation, array and hash diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 09cd437..f6a7327 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -2424,8 +2424,6 @@ divided by the natural log of N. For example: See also L for the inverse operation. -=item lstat FILEHANDLE - =item lstat EXPR =item lstat diff --git a/pp_sys.c b/pp_sys.c index 9a264c8..b4cbb55 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2497,6 +2497,9 @@ PP(pp_stat) if (PL_op->op_flags & OPf_REF) { tmpgv = cGVOP_gv; + if (PL_op->op_type == OP_LSTAT && ckWARN(WARN_IO)) + Perl_warner(aTHX_ WARN_IO, + "lstat() on filehandle %s", GvENAME(tmpgv)); do_fstat: if (tmpgv != PL_defgv) { PL_laststype = OP_STAT; diff --git a/t/pragma/warn/pp_sys b/t/pragma/warn/pp_sys index 1666b6a..eb17d68 100644 --- a/t/pragma/warn/pp_sys +++ b/t/pragma/warn/pp_sys @@ -72,6 +72,9 @@ close STDIN; flock STDIN, 8; + lstat() on filehandle %s [pp_stat] + lstat(STDIN); + warn(warn_nl, "stat"); [pp_stat] -T on unopened filehandle %s @@ -325,6 +328,24 @@ stat "abc\ndef"; EXPECT Unsuccessful stat on filename containing newline at - line 3. ######## +# pp_sys.c [pp_stat] +use Config; +BEGIN { + if ($^O eq 'd_lstat') { + print <