This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Restore errno after VMS hack in S_sv_gets_read_record.
authorCraig A. Berry <craigberry@mac.com>
Sat, 23 Mar 2013 01:39:37 +0000 (20:39 -0500)
committerCraig A. Berry <craigberry@mac.com>
Sat, 23 Mar 2013 01:39:37 +0000 (20:39 -0500)
commitd46f021e36854e800770363f716e7b4a846102ef
tree9b7a00cf1988e6dbe97975c9f42af86c38f1c99c
parente2943784ec6a8979c91e912a7b278d333c247600
Restore errno after VMS hack in S_sv_gets_read_record.

In 596a6cbd6bcaa8e6a4 I added a somewhat desperate hack to detect
if a file is record-oriented so that we preserve record semantics
when PL_rs has beeen set.  I did it by calling fstat(), which is
already a pretty icky thing to be doing on every record read, but
it turns out things are even worse becaseu fstat() sets errno in
some conditions where it's successful, specifically when the file
is a Process-Permanent File (PPF), i.e., standard input or output.

So save errno before the fstat and restore it before doing the
read so if the read fails we get a proper errno.  This gets
t/io/errno.t passing.

Side note: instead of fstat() here, we probably need to store a
pointer to the FAB (File Access Block) in the PerlIO struct so all
the metadata about the file is always accessible.  This would
require setting up completion routines in PerlIOUnix_open and
PerlIOStdio_open.
sv.c