Fix a fun bug where, every now again, ego would get its temporary files mangled

and generate invalid calls to the optimisers.

Previously ego would generate a temporary file template that looked like
/tmp/ego.A.BB.XXXXXX, call mktemp() on it to randomise the XXXXXX, and then
replace A and BB with data.

However, it used strrchr to find the A and B. Which would fine, except when
mktemp produced an A or a B in the randomised part...

This code was written on 4 March 1991. I was 16.
This commit is contained in:
David Given 2016-08-22 23:53:01 +02:00
parent 2a95b1c5e3
commit 2b6d251dec

View file

@ -418,8 +418,9 @@ int main(int argc, char* argv[])
(void)strcat(pdump, "/ego.pd.XXXXXX"); (void)strcat(pdump, "/ego.pd.XXXXXX");
(void)mktemp(pdump); (void)mktemp(pdump);
(void)strcat(tmpbufs[0], "/ego.A.BB.XXXXXX"); (void)strcat(tmpbufs[0], "/ego.XXXXXX");
(void)mktemp(tmpbufs[0]); (void)mktemp(tmpbufs[0]);
(void)strcat(tmpbufs[0], ".A.BB");
for (i = 2 * NTEMPS - 1; i >= 1; i--) for (i = 2 * NTEMPS - 1; i >= 1; i--)
{ {
(void)strcpy(tmpbufs[i], tmpbufs[0]); (void)strcpy(tmpbufs[i], tmpbufs[0]);