Change 33788 by [EMAIL PROTECTED] on 2008/05/04 22:25:44

        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.

Affected files ...

... //depot/perl/sv.c#1538 edit

Differences ...

==== //depot/perl/sv.c#1538 (text) ====
Index: perl/sv.c
--- perl/sv.c#1537~33669~       2008-04-11 06:45:43.000000000 -0700
+++ perl/sv.c   2008-05-04 15:25:44.000000000 -0700
@@ -6636,6 +6636,9 @@
       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 @@
       /* 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
End of Patch.

Reply via email to