Skip to content

Commit 932bc02

Browse files
committed
Try to create the sort file at startup.
If a bad path for FORMTMPSORT is specified, FORM doesn't notice until it tries to create a sort file and can't. In principle one can create a script which takes a long time to reach this point. Try to create the file immediately at startup, and Terminate if this fails.
1 parent 83e3d41 commit 932bc02

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

check/features.frm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,3 +1111,13 @@ format C;
11111111
assert succeeded?
11121112
assert !(file("out.c") =~ /[_] [+]= /)
11131113
*--#] Issue392_ContinuationLines_0 :
1114+
*--#[ TempSortDir :
1115+
#: TempSortDir bad/path
1116+
Local test = 1;
1117+
.end
1118+
if mpi?
1119+
assert runtime_error?("Could not create sort file: bad/path/0formxxx.sor")
1120+
else
1121+
assert runtime_error?("Could not create sort file: bad/path/xformxxx.sor")
1122+
end
1123+
*--#] TempSortDir :

sources/startup.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,16 @@ classic:;
801801
while ( *t ) { *s++ = *t++; i++; }
802802
s[-2] = 'o'; *s = 0;
803803
}
804+
/*
805+
Try to create the sort file already, so we can Terminate earlier if this fails.
806+
*/
807+
if ( ( AM.S0->file.handle = CreateFile((char *)AM.S0->file.name) ) < 0 ) {
808+
MesPrint("Could not create sort file: %s", AM.S0->file.name);
809+
Terminate(-1);
810+
};
811+
/* Reset the file.handle and clean up the test file */
812+
AM.S0->file.handle = -1;
813+
remove(AM.S0->file.name);
804814
/*
805815
With the stage4 and scratch file names we have to be a bit more careful.
806816
They are to be allocated after the threads are initialized when there

0 commit comments

Comments
 (0)