[Info-vax] VSI roadmap

Arne Vajhøj arne at vajhoej.dk
Sat Aug 26 13:28:32 EDT 2023


On 8/25/2023 12:17 AM, terry-... at glaver.org wrote:
> On Wednesday, August 23, 2023 at 10:47:38 AM UTC-4, David Jones
> wrote:
>> To support any number of Unix applications reading of files, the C
>> runtime includes fgets() to return what is logically a record. So
>> what?
> 
> That fails woefully even on some text file formats. I probably sound
> like I'm beating a dead horse, but go look at ckvfio.c for an idea of
> what is really needed to get text lines out of RMS regardless of the
> file format. For those who say "RMS contains all of the necessary
> info", go look at how True BASIC stores the source code for
> user-written programs (hint: RMS undefined).

RFM=UDF is not intended to be used for text files.

In general the VMS expectation is that operations
going through RMS should work transparently independent
of ORG and RFM to the extent that it makes logical
sense.

It seems to almost be the case.

Small test on VMS Alpha 8.4.

ffun.com:

$ type ffun_c.c
$ cc ffun_c
$ link ffun_c
$ type ffun_p.pas
$ pas ffun_p
$ link ffun_p
$ create ffun.txt
AA
BB
CC
$
$ call fcheck
$ convert/fdl="record; format stream_lf" ffun.txt ffun.txt
$ call fcheck
$ convert/fdl="record; format stream" ffun.txt ffun.txt
$ call fcheck
$ convert/fdl="record; format stream_cr" ffun.txt ffun.txt
$ call fcheck
$ convert/fdl="record; format vfc" ffun.txt ffun.txt
$ call fcheck
$ convert/fdl="record; format fixed; size 2" ffun.txt ffun.txt
$ call fcheck
$ convert/fdl="file; organization indexed; key 0; seg0_length 1; 
seg0_position 0; type string" ffun.txt ffun.txt
$ call fcheck
$ exit
$!
$ fcheck: subroutine
$ write sys$output f$fao("org=!AS rfm=!AS eof=!UL ffb=!UL", 
f$file("ffun.txt", "org"), f$file("ffun.txt", "rfm"), f$file("ffun.txt",
  "eof"), f$file("ffun.txt", "ffb"))
$ on error then continue
$ write sys$output "C"
$ run ffun_c
$ write sys$output "Pascal"
$ run ffun_p
$ write sys$output "DCL"
$ open/read f ffun.txt
$ loop:
$    read/end=endloop f line
$    write sys$output "|" + line + "|"
$    goto loop
$ endloop:
$ close f
$ return
$ endsubroutine

output:

#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
     FILE *fp;
     char line[32768];
     fp = fopen("ffun.txt", "r");
     line[0] = '|';
     while(fgets(line + 1, sizeof(line) - 1, fp))
     {
         if(line[strlen(line) - 1] == '\n') line[strlen(line) - 1] = 0;
         strcat(line, "|");
         puts(line);
     }
     fclose(fp);
     return 0;
}
program ffun(input,output);

var
    f : text;
    line : varying [32767] of char;

begin
    open(f, 'ffun.txt', old);
    reset(f);
    while not eof(f) do begin
       readln(f, line);
       writeln('|' + line + '|');
    end;
    close(f);
end.
org=SEQ rfm=VAR eof=1 ffb=12
C
|AA|
|BB|
|CC|
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=SEQ rfm=STMLF eof=1 ffb=9
C
|AA|
|BB|
|CC|
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=SEQ rfm=STM eof=1 ffb=12
C
|AA|
|BB|
|CC|
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=SEQ rfm=STMCR eof=1 ffb=9
C
|AA|
|BB|
|CC|
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=SEQ rfm=VFC eof=1 ffb=18
C
||
||
||
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=SEQ rfm=FIX eof=1 ffb=6
C
|AA|
|BB|
|CC|
Pascal
|AA|
|BB|
|CC|
DCL
|AA|
|BB|
|CC|
org=IDX rfm=VAR eof=16 ffb=0
C
|AA|
|BB|
|CC|
Pascal
%PAS-F-TEXREQSEQ, textfiles require sequential organization and access
   File "F"  Filename "DISK2:[ARNE]ffun.txt;8"
%TRACE-F-TRACEBACK, symbolic stack dump follows
   image    module    routine             line      rel PC           abs PC
  PAS$RTL                                    0 00000000000200BC 
000000007BFE80BC
  PAS$RTL                                    0 00000000000361C8 
000000007BFFE1C8
  PAS$RTL                                    0 00000000000228E8 
000000007BFEA8E8
  PAS$RTL                                    0 00000000000200BC 
000000007BFE80BC
  PAS$RTL                                    0 0000000000021584 
000000007BFE9584
  ffun_p  FFUN  FFUN                         8 0000000000000074 
0000000000020074
                                             0 FFFFFFFF80340964 
FFFFFFFF80340964
%TRACE-I-END, end of TRACE stack dump
DCL
|AA|
|BB|
|CC|

It looks like Pascal text files has an explicit test requiring
ORG=SEQ instead of just calling SYS$GET no matter what. There
is probably a good reason for that.

And then C fgets fail on VFC. It looks like it read the
control bytes as data. WTF? I believe it has been revealed that
C IO does not use SYS$GET to read records but SYS$READ to read
blocks, so there is a reason why C is different. But I would
still consider it a bug.

Arne





More information about the Info-vax mailing list