diff options
author | Craig A. Berry <craigberry@mac.com> | 2008-05-04 22:25:44 +0000 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2008-05-04 22:25:44 +0000 |
commit | 048d9da8ec2370ce3e00d2fda9649ad63736ab2f (patch) | |
tree | 3fcfc3335755836a8c1f4809fd62d9825fe59966 /sv.c | |
parent | d7a49bad0e1537084bd88728b2db4b4913a3dc18 (diff) | |
download | perl-048d9da8ec2370ce3e00d2fda9649ad63736ab2f.tar.gz |
Record-style reads in Perl_sv_gets have to be done with read(), not
fread() on VMS, and have been for some time. Except that ain't gonna
work with PerlIO::Scalar's in-memory files. Old bug exposed by new
test in #33769.
p4raw-id: //depot/perl@33788
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -6636,6 +6636,9 @@ Perl_sv_gets(pTHX_ register SV *const sv, register PerlIO *const fp, I32 append) I32 bytesread; char *buffer; U32 recsize; +#ifdef VMS + int fd; +#endif /* Grab the size of the record we're getting */ recsize = SvUV(SvRV(PL_rs)); /* RsRECORD() guarantees > 0. */ @@ -6647,7 +6650,13 @@ Perl_sv_gets(pTHX_ register SV *const sv, register PerlIO *const fp, I32 append) /* doing, but we've got no other real choice - except avoid stdio as implementation - perhaps write a :vms layer ? */ - bytesread = PerlLIO_read(PerlIO_fileno(fp), buffer, recsize); + fd = PerlIO_fileno(fp); + if (fd == -1) { /* in-memory file from PerlIO::Scalar */ + bytesread = PerlIO_read(fp, buffer, recsize); + } + else { + bytesread = PerlLIO_read(fd, buffer, recsize); + } #else bytesread = PerlIO_read(fp, buffer, recsize); #endif |