summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorHans Mulder <hansmu@xs4all.nl>1998-06-05 04:08:40 -0700
committerGurusamy Sarathy <gsar@cpan.org>1998-06-10 06:51:08 +0000
commit5b2b9c687790241e85aa7b76aaeec8b744ce6b49 (patch)
tree93b74d9f604f921db988b77aa85c2a408e97b2bd /sv.c
parenta9fd575dd92ad717baa6b7171a8f5bbb5221fcc7 (diff)
downloadperl-5b2b9c687790241e85aa7b76aaeec8b744ce6b49.tar.gz
Mangled patch, needed hand-tweaks, along with binmode for rs.t:
Message-Id: <3.0.5.32.19980605110840.009e12b0@ous.edu> Subject: Re: [PATCH 5.004_66]Add record read capability to <> p4raw-id: //depot/perl@1099
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index f5a979a1c3..023693f7b0 100644
--- a/sv.c
+++ b/sv.c
@@ -3153,6 +3153,31 @@ sv_gets(register SV *sv, register PerlIO *fp, I32 append)
rsptr = NULL;
rslen = 0;
}
+ else if (RsRECORD(rs)) {
+ I32 recsize, bytesread;
+ char *buffer;
+
+ /* Grab the size of the record we're getting */
+ recsize = SvIV(SvRV(rs));
+ (void)SvPOK_only(sv); /* Validate pointer */
+ /* Make sure we've got the room to yank in the whole thing */
+ if (SvLEN(sv) <= recsize + 3) {
+ /* No, so make it bigger */
+ SvGROW(sv, recsize + 3);
+ }
+ buffer = SvPVX(sv); /* Get the location of the final buffer */
+ /* Go yank in */
+#ifdef VMS
+ /* VMS wants read instead of fread, because fread doesn't respect */
+ /* RMS record boundaries. This is not necessarily a good thing to be */
+ /* doing, but we've got no other real choice */
+ bytesread = PerlLIO_read(PerlIO_fileno(fp), buffer, recsize);
+#else
+ bytesread = PerlIO_read(fp, buffer, recsize);
+#endif
+ SvCUR_set(sv, bytesread);
+ return(SvCUR(sv) ? SvPVX(sv) : Nullch);
+ }
else if (RsPARA(rs)) {
rsptr = "\n\n";
rslen = 2;