diff options
author | Hans Mulder <hansmu@xs4all.nl> | 1998-06-05 04:08:40 -0700 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1998-06-10 06:51:08 +0000 |
commit | 5b2b9c687790241e85aa7b76aaeec8b744ce6b49 (patch) | |
tree | 93b74d9f604f921db988b77aa85c2a408e97b2bd /sv.c | |
parent | a9fd575dd92ad717baa6b7171a8f5bbb5221fcc7 (diff) | |
download | perl-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.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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; |