diff options
author | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2002-02-01 16:12:50 +0100 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2002-02-01 14:44:39 +0000 |
commit | 3db621fff0190e634928562c9f2fd308ab651d3c (patch) | |
tree | 483146c2f5268e75f8a42057eb89103fdfed5420 | |
parent | fe69a90c3f7231026ad863ff8acde1f0e0b750c3 (diff) | |
download | perl-3db621fff0190e634928562c9f2fd308ab651d3c.tar.gz |
make "lstat FH" croak
Message-ID: <20020201151250.A738@rafael>
p4raw-id: //depot/perl@14513
-rw-r--r-- | pod/perldiag.pod | 11 | ||||
-rw-r--r-- | pp_sys.c | 6 | ||||
-rwxr-xr-x | t/op/stat.t | 15 |
3 files changed, 16 insertions, 16 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 56b6950e9f..76fb6aa57d 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -1846,12 +1846,6 @@ effective uids or gids failed. to check the return value of your socket() call? See L<perlfunc/listen>. -=item lstat() on filehandle %s - -(W io) You tried to do an 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 @@ -4220,6 +4214,11 @@ supported. it already went past any symlink you are presumably trying to look for. Use a filename instead. +=item You can't use lstat() on a filehandle + +(F) You tried to do an lstat on a filehandle. lstat() makes sense only +on filenames. + =item YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET! (F) And you probably never will, because you probably don't have the @@ -2726,12 +2726,10 @@ PP(pp_stat) if (PL_op->op_flags & OPf_REF) { gv = cGVOP_gv; if (PL_op->op_type == OP_LSTAT) { + if (gv != PL_defgv) + Perl_croak(aTHX_ "You can't use lstat() on a filehandle"); if (PL_laststype != OP_LSTAT) Perl_croak(aTHX_ "The stat preceding lstat() wasn't an lstat"); - if (ckWARN(WARN_IO) && gv != PL_defgv) - Perl_warner(aTHX_ WARN_IO, - "lstat() on filehandle %s", GvENAME(gv)); - /* Perl_my_lstat (-l) croak's on filehandle, why warn here? */ } do_fstat: diff --git a/t/op/stat.t b/t/op/stat.t index 81fd74ff87..ad87c25b0b 100755 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -9,7 +9,7 @@ BEGIN { use Config; use File::Spec; -plan tests => 74; +plan tests => 75; my $Perl = which_perl(); @@ -384,15 +384,18 @@ SKIP: { stat $0; eval { lstat _ }; - ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/, + like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/, 'lstat _ croaks after stat' ); eval { -l _ }; - ok( $@ =~ /^The stat preceding -l _ wasn't an lstat/, + like( $@, qr/^The stat preceding -l _ wasn't an lstat/, '-l _ croaks after stat' ); eval { lstat STDIN }; - ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/, + like( $@, qr/^You can't use lstat\(\) on a filehandle/, 'lstat FILEHANDLE croaks' ); + eval { -l STDIN }; + like( $@, qr/^You can't use -l on a filehandle/, + '-l FILEHANDLE croaks' ); # bug id 20020124.004 # If we have d_lstat, we should have symlink() @@ -401,10 +404,10 @@ SKIP: { lstat $linkname; -T _; eval { lstat _ }; - ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/, + like( $@, qr/^The stat preceding lstat\(\) wasn't an lstat/, 'lstat croaks after -T _' ); eval { -l _ }; - ok( $@ =~ /^The stat preceding -l _ wasn't an lstat/, + like( $@, qr/^The stat preceding -l _ wasn't an lstat/, '-l _ croaks after -T _' ); unlink $linkname or print "# unlink $linkname failed: $!\n"; } |