--- ray/src/common/caldefn.c 2022/03/30 16:00:56 2.32 +++ ray/src/common/caldefn.c 2023/09/26 00:14:02 2.35 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: caldefn.c,v 2.32 2022/03/30 16:00:56 greg Exp $"; +static const char RCSid[] = "$Id: caldefn.c,v 2.35 2023/09/26 00:14:02 greg Exp $"; #endif /* * Store variable definitions. @@ -78,11 +78,18 @@ fcompile( /* get definitions from a file */ eputs(": cannot open\n"); quit(1); } - initfile(fp, fname, 0); +#ifdef getc_unlocked /* avoid stupid semaphores */ + flockfile(fp); +#endif + initfile(fp, fname, 0); while (nextc != EOF) getstatement(); if (fname != NULL) fclose(fp); +#ifdef getc_unlocked + else + funlockfile(fp); +#endif } @@ -369,11 +376,13 @@ dcleanup( /* clear definitions (0->vars,1->output,2-> else dclear(vp->name); } - if (lvl >= 1) { - for (ep = outchan; ep != NULL; ep = ep->sibling) + if (lvl >= 1) + while (outchan != NULL) { + ep = outchan; + outchan = ep->sibling; + ep->sibling = NULL; epfree(ep); - outchan = NULL; - } + } } @@ -443,7 +452,7 @@ libupdate( /* update library links */ /* if fn is NULL then relink all */ for (i = 0; i < NHASH; i++) for (vp = hashtbl[i]; vp != NULL; vp = vp->next) - if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name)) + if ((vp->lib != NULL) | (fn == NULL) || !strcmp(fn, vp->name)) vp->lib = liblookup(vp->name); } @@ -469,7 +478,7 @@ varfree( /* release link to variable */ vp->next = ln->next; } freestr(ln->name); - efree((char *)ln); + efree(ln); } @@ -621,7 +630,7 @@ getdefn(void) { EPNODE *ep1, *ep2; - if (!isalpha(nextc) && nextc != CNTXMARK) + if (!isalpha(nextc) & (nextc != CNTXMARK)) syntax("illegal variable name"); ep1 = newnode(); @@ -650,7 +659,7 @@ getdefn(void) curfunc = ep1; } - if (nextc != '=' && nextc != ':') + if ((nextc != '=') & (nextc != ':')) syntax("'=' or ':' expected"); ep2 = newnode();