From: Craig A. Berry Date: Sun, 4 May 2008 22:25:44 +0000 (+0000) Subject: Record-style reads in Perl_sv_gets have to be done with read(), not X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=048d9da8ec2370ce3e00d2fda9649ad63736ab2f;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/sv.c b/sv.c index a61f90a..8f94350 100644 --- a/sv.c +++ b/sv.c @@ -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