Skip to content

Commit

Permalink
SREAD may fail, as wrong open mode (DSN:) is used #, but DDN is requi…
Browse files Browse the repository at this point in the history
…red. Problem is fixed.
  • Loading branch information
Peter-Jacob committed Jul 11, 2024
1 parent 5e4f54b commit 4d5cd75
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/preload.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,22 @@ RxPreLoaded(RxFile *rxf) {
"member=strip(peeks(jfcb+44,8)); call sset(s1,,'#'ddn' $'dsn' *'member); return;"
"__tcb: return peeka(540); __Tiot: return peeka(__tcb()+12)");
} else if (strcmp((const char *) LSTR(rxf->name), "PEEKS") == 0) {
















RxPreLoad(rxf, "PEEKS: return storage(d2x(arg(1)),arg(2));");
} else if (strcmp((const char *) LSTR(rxf->name), "VERSION") == 0) {
RxPreLoad(rxf, "VERSION: Procedure;parse upper arg mode;"
Expand Down Expand Up @@ -273,11 +289,11 @@ RxPreLoaded(RxFile *rxf) {
"if _#llp0=='PULL' then return llGET(arg(2),'FIFO');"
"if _#llp0=='CREATE' then return llCreate(arg(2)); call error 'invalid FIFO request: '_#llp0;");
} else if (strcmp(LSTR(rxf->name), "SREAD") == 0) {
RxPreLoad(rxf,"SREAD: procedure; trace off; parse upper arg dsn;"
RxPreLoad(rxf,"SREAD: procedure; trace off; parse upper arg dsn,maxrec;"
"dsub=c2d(substr(dsn,1,1)); if dsub=125 | dsub=127 then do;"
"ddname='X'right(time('LS'),7);"
"call allocate(ddname,dsn); alc=1; end; else ddname=dsn;"
"sname=__sread(ddname);"
"sname=__sread(ddname,maxrec);"
"if alc=1 then call free ddname; return sname;");
} else if (strcmp(LSTR(rxf->name), "SWRITE") == 0) {
RxPreLoad(rxf,"SWRITE: procedure; trace off; parse upper arg sname,dsn;"
Expand Down
3 changes: 3 additions & 0 deletions src/rxmvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3305,6 +3305,7 @@ void R_sarray(int func) {
void R_sread(int func) {
int sname,recs=0,ssize,ii;
long smax,off1,off2;
char *_style_old = _style;
FILE *fk; // file handle
char record[16385];
char *pos;
Expand All @@ -3319,7 +3320,9 @@ void R_sread(int func) {
sname=LINT(*ARGR);
sindex= (char **) sarray[sname];

_style = "//DDN:";
fk=fopen(LSTR(*ARG1), "R");
_style=_style_old;
if (fk == NULL) {
Licpy(ARGR, -1);
return;
Expand Down

0 comments on commit 4d5cd75

Please sign in to comment.