Change 14506 by jhi@alpha on 2002/01/31 15:27:49

        Subject: [PATCH 20020124.004] forbid -l _ after -T _
        From: Rafael Garcia-Suarez <[EMAIL PROTECTED]>
        Date: Thu, 31 Jan 2002 14:37:52 +0100
        Message-ID: <20020131143752.A1452@rafael>

Affected files ...

.... //depot/perl/pod/perlfunc.pod#295 edit
.... //depot/perl/pp_sys.c#278 edit
.... //depot/perl/t/lib/warnings/pp_sys#2 edit
.... //depot/perl/t/op/stat.t#58 edit

Differences ...

==== //depot/perl/pod/perlfunc.pod#295 (text) ====
Index: perl/pod/perlfunc.pod
--- perl/pod/perlfunc.pod.~1~   Thu Jan 31 08:45:05 2002
+++ perl/pod/perlfunc.pod       Thu Jan 31 08:45:05 2002
@@ -350,7 +350,9 @@
 structure of the previous file test (or stat operator) is used, saving
 a system call.  (This doesn't work with C<-t>, and you need to remember
 that lstat() and C<-l> will leave values in the stat structure for the
-symbolic link, not the real file.)  Example:
+symbolic link, not the real file.)  (Also, if the stat buffer was filled by
+a C<lstat> call, C<-T> and C<-B> will reset it with the results of C<stat _>).
+Example:
 
     print "Can do.\n" if -r $a || -w _ || -x _;
 

==== //depot/perl/pp_sys.c#278 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c.~1~   Thu Jan 31 08:45:05 2002
+++ perl/pp_sys.c       Thu Jan 31 08:45:05 2002
@@ -3311,6 +3311,7 @@
       really_filename:
        PL_statgv = Nullgv;
        PL_laststatval = -1;
+       PL_laststype = OP_STAT;
        sv_setpv(PL_statname, SvPV(sv, n_a));
        if (!(fp = PerlIO_open(SvPVX(PL_statname), "r"))) {
            if (ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))

==== //depot/perl/t/lib/warnings/pp_sys#2 (text) ====
Index: perl/t/lib/warnings/pp_sys
--- perl/t/lib/warnings/pp_sys.~1~      Thu Jan 31 08:45:05 2002
+++ perl/t/lib/warnings/pp_sys  Thu Jan 31 08:45:05 2002
@@ -83,9 +83,6 @@
     flock STDIN, 8;
     flock $a, 8;
 
-  The stat preceding lstat() wasn't an lstat %s        [pp_stat]
-    lstat(STDIN);
-
   warn(warn_nl, "stat");                       [pp_stat]
 
   -T on closed filehandle %s
@@ -347,24 +344,6 @@
 EXPECT
 Unsuccessful stat on filename containing newline at - line 3.
 ########
-# pp_sys.c [pp_stat]
-use Config; 
-BEGIN { 
-  if ($^O eq 'd_lstat') {
-    print <<EOM ;
-SKIPPED
-# lstat not present
-EOM
-    exit ;
-  } 
-}
-use warnings 'io' ;
-lstat(STDIN) ;
-no warnings 'io' ;
-lstat(STDIN) ;
-EXPECT
-The stat preceding lstat() wasn't an lstat at - line 13.
-########
 # pp_sys.c [pp_fttext]
 use warnings qw(unopened closed) ;
 close STDIN ; 

==== //depot/perl/t/op/stat.t#58 (xtext) ====
Index: perl/t/op/stat.t
--- perl/t/op/stat.t.~1~        Thu Jan 31 08:45:05 2002
+++ perl/t/op/stat.t    Thu Jan 31 08:45:05 2002
@@ -9,7 +9,7 @@
 use Config;
 use File::Spec;
 
-plan tests => 69;
+plan tests => 74;
 
 my $Perl = which_perl();
 
@@ -376,3 +376,33 @@
 # bug id 20011101.069
 my @r = \stat(".");
 is(scalar @r, 13,   'stat returns full 13 elements');
+
+SKIP: {
+    skip "No lstat", 2 unless $Config{d_lstat};
+
+    stat $0;
+    eval { lstat _ };
+    ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/,
+       'lstat _ croaks after stat' );
+    eval { -l _ };
+    ok( $@ =~ /^The stat preceding -l _ wasn't an lstat/,
+       '-l _ croaks after stat' );
+
+    eval { lstat STDIN };
+    ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/,
+       'lstat FILEHANDLE croaks' );
+
+    # bug id 20020124.004
+    # If we have d_lstat, we should have symlink()
+    my $linkname = 'dolzero';
+    symlink $0, $linkname or die "# Can't symlink $0: $!";
+    lstat $linkname;
+    -T _;
+    eval { lstat _ };
+    ok( $@ =~ /^The stat preceding lstat\(\) wasn't an lstat/,
+       'lstat croaks after -T _' );
+    eval { -l _ };
+    ok( $@ =~ /^The stat preceding -l _ wasn't an lstat/,
+       '-l _ croaks after -T _' );
+    unlink $linkname or print "# unlink $linkname failed: $!\n";
+}
End of Patch.

Reply via email to