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.
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";
+}
*/
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
}
}
}