From 31b139ba853d7a7a7b30c4c0e7a90020a641854d Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 14 Jan 2012 00:00:26 -0800 Subject: [PATCH] Make -l HANDLE set PL_laststatval with fatal warnings Fatal warnings were preventing it from being set, because the warning came first. (PL_laststatval records the success status of the previous stat.) --- doio.c | 3 ++- t/op/filetest.t | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doio.c b/doio.c index b0c5a69..1a03103 100644 --- a/doio.c +++ b/doio.c @@ -1336,12 +1336,13 @@ Perl_my_lstat_flags(pTHX_ const U32 flags) Perl_croak(aTHX_ no_prev_lstat); return PL_laststatval; } + PL_laststatval = -1; if (ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %"HEKf, HEKfARG(GvENAME_HEK(cGVOP_gv))); } - return (PL_laststatval = -1); + return -1; } else if (PL_op->op_private & OPpFT_STACKED) { if (PL_laststype != OP_LSTAT) diff --git a/t/op/filetest.t b/t/op/filetest.t index 26d3cdd..86ad235 100644 --- a/t/op/filetest.t +++ b/t/op/filetest.t @@ -10,7 +10,7 @@ BEGIN { } use Config; -plan(tests => 44 + 27*14); +plan(tests => 45 + 27*14); ok( -d 'op' ); ok( -f 'TEST' ); @@ -237,6 +237,12 @@ for my $op (split //, "rwxoRWXOezsfdlpSbctugkTMBAC") { is $foo[0], "bar", '-l bareword does not corrupt the stack'; } +# -l and fatal warnings +stat "test.pl"; +eval { use warnings FATAL => io; -l cradd }; +ok !stat _, + 'fatal warnings do not prevent -l HANDLE from setting stat status'; + # File test ops should not call get-magic on the topmost SV on the stack if # it belongs to another op. { -- 2.7.4