summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2010-11-17 22:10:57 -0600
committerCraig A. Berry <craigberry@mac.com>2010-11-17 22:24:41 -0600
commit8c8488cd4fce90cb5c03fb3f89e89c05e5275498 (patch)
treea386a6434ec9abaaa91f4067ecfe5b12d85127b0 /perlio.c
parente4ed29fbb903ac6b15b0ec4a5a6696aaa73401f2 (diff)
downloadperl-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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/perlio.c b/perlio.c
index 13b135181d..4620ecd97f 100644
--- a/perlio.c
+++ b/perlio.c
@@ -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
}
}
}