diff options
-rw-r--r-- | ext/VMS-Stdio/t/vms_stdio.t | 32 | ||||
-rw-r--r-- | perlio.c | 16 |
2 files changed, 47 insertions, 1 deletions
diff --git a/ext/VMS-Stdio/t/vms_stdio.t b/ext/VMS-Stdio/t/vms_stdio.t index 77505d8fac..64fe3a3573 100644 --- a/ext/VMS-Stdio/t/vms_stdio.t +++ b/ext/VMS-Stdio/t/vms_stdio.t @@ -2,7 +2,7 @@ use VMS::Stdio; import VMS::Stdio qw(&flush &getname &rewind &sync &tmpnam); -print "1..18\n"; +print "1..19\n"; print +(defined(&getname) ? '' : 'not '), "ok 1\n"; #VMS can pretend that it is UNIX. @@ -77,3 +77,33 @@ close $sfh; unlink("$name.tmp"); print +($defs[0] eq uc($ENV{'SYS$LOGIN'}) ? '' : "not ($defs[0]) "),"ok 18\n"; #print +($defs[1] eq VMS::Filespec::rmsexpand('[-]') ? '' : "not ($defs[1]) "),"ok 19\n"; + +# This is not exactly a test of VMS::Stdio, but we need it to create a record-oriented +# file and then make sure perlio can write to it without introducing spurious newlines. + +1 while unlink 'rectest.lis'; +END { 1 while unlink 'rectest.lis'; } + +$fh = VMS::Stdio::vmsopen('>rectest.lis', 'rfm=var', 'rat=cr') + or die "Couldn't open rectest.lis: $!"; +close $fh; + +open $fh, '>', 'rectest.lis' + or die "Couldn't open rectest.lis: $!"; + +for (1..20) { print $fh ('Z' x 2048) . "\n" ; } + +close $fh; + +open $fh, '<', 'rectest.lis' + or die "Couldn't open rectest.lis: $!"; + +my @records = <$fh>; +close $fh; + +if (scalar(@records) == 20) { + print "ok 19\n"; +} +else { + print "not ok 18 # Expected 20 got " . scalar(@records) . "\n"; +} @@ -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 } } } |