diff options
author | Craig A. Berry <craigberry@mac.com> | 2010-11-17 22:10:57 -0600 |
---|---|---|
committer | Craig A. Berry <craigberry@mac.com> | 2010-11-17 22:24:41 -0600 |
commit | 8c8488cd4fce90cb5c03fb3f89e89c05e5275498 (patch) | |
tree | a386a6434ec9abaaa91f4067ecfe5b12d85127b0 /perlio.c | |
parent | e4ed29fbb903ac6b15b0ec4a5a6696aaa73401f2 (diff) | |
download | perl-8c8488cd4fce90cb5c03fb3f89e89c05e5275498.tar.gz |
Make perlio line buffer VMS record-oriented files on output.
When perlio flushes down to the unix layer, it can introduce a
spurious record boundary when writing to a record-oriented file.
Perl may create such files when doing edit-in-place or any other
context where the file format is inherited from a previous
version of the file.
The problem can be eliminated by enabling line buffering on such
files when they are opened. This was a regression in 5.10.0 since
before that stdio's buffering performed the same function.
N.B. Lines longer than the size of the perlio buffer will still
result in multiple records -- a larger buffer may be necessary.
For more details and discussion see:
http://www.nntp.perl.org/group/perl.vmsperl/2010/11/msg15419.html
Thanks to Martin Zinser for the problem report.
Diffstat (limited to 'perlio.c')
-rw-r--r-- | perlio.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -3761,6 +3761,22 @@ PerlIOBuf_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, */ PerlLIO_setmode(fd, O_BINARY); #endif +#ifdef VMS +#include <rms.h> + /* Enable line buffering with record-oriented regular files + * so we don't introduce an extraneous record boundary when + * the buffer fills up. + */ + if (PerlIOBase(f)->flags & PERLIO_F_CANWRITE) { + Stat_t st; + if (PerlLIO_fstat(fd, &st) == 0 + && S_ISREG(st.st_mode) + && (st.st_fab_rfm == FAB$C_VAR + || st.st_fab_rfm == FAB$C_VFC)) { + PerlIOBase(f)->flags |= PERLIO_F_LINEBUF; + } + } +#endif } } } |