From 5731662b7617da2ff1626044f081de38b50a0ddc Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Thu, 12 Jan 2012 14:32:30 -0800 Subject: [PATCH] Make -T HANDLE set the last stat type This was brought up in bug #77388. --- pp_sys.c | 1 + t/op/filetest.t | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pp_sys.c b/pp_sys.c index b8c212c..bd552a1 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3328,6 +3328,7 @@ PP(pp_fttext) if (! PerlIO_has_base(IoIFP(io))) DIE(aTHX_ "-T and -B not implemented on filehandles"); PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache); + PL_laststype = OP_STAT; if (PL_laststatval < 0) RETPUSHUNDEF; if (S_ISDIR(PL_statcache.st_mode)) { /* handle NFS glitch */ diff --git a/t/op/filetest.t b/t/op/filetest.t index d013cce..5cc83d7 100644 --- a/t/op/filetest.t +++ b/t/op/filetest.t @@ -10,7 +10,7 @@ BEGIN { } use Config; -plan(tests => 34 + 27*14); +plan(tests => 35 + 27*14); ok( -d 'op' ); ok( -f 'TEST' ); @@ -247,3 +247,13 @@ for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") { push my @a, $t, -t; is $w, 1, 'file test does not call FETCH on stack item not its own'; } + +# Test that -T HANDLE sets the last stat type +SKIP: { + skip "no -T on filehandles", 1 unless eval { -T STDERR; 1 }; + -l "perl.c"; # last stat type is now lstat + -T STDERR; # should set it to stat, since -T does a stat + eval { -l _ }; # should die, because the last stat type is not lstat + like $@, qr/^The stat preceding -l _ wasn't an lstat at /, + '-T HANDLE sets the stat type'; +} -- 2.7.4