This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
-T "unreadable file" should set stat info consistently
authorFather Chrysostomos <sprout@cpan.org>
Sat, 14 Jan 2012 08:23:23 +0000 (00:23 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 14 Jan 2012 08:55:20 +0000 (00:55 -0800)
commitad2d99e390e75f36bbfc104614c4b9e4c22fe450
tree5db20ce135c197290eb6e511bf448daf8c97373b
parent7b64ff23e735d414eea886bd2bf2b6231acbd7a2
-T "unreadable file" should set stat info consistently

This was mentioned in ticket #77388.  It turns out to be
related to #4253.

If the file cannot be opened, -T and -B on filenames set the last han-
dle to null and set the last stat type to stat, but leave the actual
stat buffer and success status as they were.

That means that stat(_) will continue to return the previous buffer,
but lstat(_) will no longer work.

This is another of those inconsistent cases where the internal stat
info is only partially set.

Originally, this code would set PL_laststatval (the success status) to
-1.  Commit 25988e07 (the patch in ticket #4253) intentionally changed
this to make -T _ less suprising on read-only files.

But the patch ended up affecting -T with an explicit file name, too.
It also only partially fixed things for -T _, because the last stat
type *was* still being set.

This commit changes it to set all the stat info, for explicit file
names, or no stat info, for _ (if the previous stat was with a
file name).
pp_sys.c
t/op/filetest.t
t/op/stat.t