From 020cc77c5665898032456aabfe6ae45ccf11f874 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Fri, 13 Jan 2012 16:43:30 -0800 Subject: [PATCH] stat $ioref should reset the internal stat type In addition to a stat buffer, Perl keeps track internally of which type of stat was done last, either stat or lstat, so that lstat _ can die if the previous type was stat. This was not being reset for stat $ioref. Filetest ops were fine. --- pp_sys.c | 1 + t/op/stat.t | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pp_sys.c b/pp_sys.c index bd552a1..430aa7c 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2802,6 +2802,7 @@ PP(pp_stat) io = MUTABLE_IO(SvRV(sv)); if (PL_op->op_type == OP_LSTAT) goto do_fstat_warning_check; + PL_laststype = OP_STAT; goto do_fstat_have_io; } diff --git a/t/op/stat.t b/t/op/stat.t index fccadba..d2ce8d1 100644 --- a/t/op/stat.t +++ b/t/op/stat.t @@ -20,7 +20,7 @@ if(eval {require File::Spec; 1}) { } -plan tests => 109; +plan tests => 110; my $Perl = which_perl(); @@ -456,6 +456,15 @@ eval { lstat _ }; is( "$@", "", "lstat _ ok after lstat" ); eval { -l _ }; is( "$@", "", "-l _ ok after lstat" ); + +lstat "test.pl"; +{ + open my $fh, "test.pl"; + stat *$fh{IO}; + eval { lstat _ } +} +like $@, qr/^The stat preceding lstat\(\) wasn't an lstat at /, +'stat $ioref resets stat type'; SKIP: { skip "No lstat", 2 unless $Config{d_lstat}; -- 2.7.4