From: Father Chrysostomos Date: Sat, 14 Jan 2012 00:43:30 +0000 (-0800) Subject: stat $ioref should reset the internal stat type X-Git-Tag: accepted/trunk/20130322.191538~1194 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=020cc77c5665898032456aabfe6ae45ccf11f874;p=platform%2Fupstream%2Fperl.git 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. --- 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};