--- ray/src/common/caldefn.c 2022/03/12 15:50:13 2.30 +++ ray/src/common/caldefn.c 2023/02/07 20:28:16 2.34 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: caldefn.c,v 2.30 2022/03/12 15:50:13 greg Exp $"; +static const char RCSid[] = "$Id: caldefn.c,v 2.34 2023/02/07 20:28:16 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 } @@ -200,16 +207,17 @@ vardefined( /* return '=' or ':' if variable/constant char *name ) { - EPNODE *dp; + EPNODE *dp = dlookup(name); - if ((dp = dlookup(name)) == NULL || dp->v.kid->type != SYM) + if (dp == NULL || dp->v.kid->type != SYM) return(0); + return(dp->type); } char * -setcontext( /* set a new context path */ +calcontext( /* set a new context path */ char *ctx ) { @@ -250,7 +258,7 @@ pushcontext( /* push on another context */ int n; strcpy(oldcontext, context); /* save old context */ - setcontext(ctx); /* set new context */ + calcontext(ctx); /* set new context */ n = strlen(context); /* tack on old */ if (n+strlen(oldcontext) > MAXCNTX) { strncpy(context+n, oldcontext, MAXCNTX-n); @@ -442,7 +450,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); } @@ -620,7 +628,7 @@ getdefn(void) { EPNODE *ep1, *ep2; - if (!isalpha(nextc) && nextc != CNTXMARK) + if (!isalpha(nextc) & (nextc != CNTXMARK)) syntax("illegal variable name"); ep1 = newnode(); @@ -649,7 +657,7 @@ getdefn(void) curfunc = ep1; } - if (nextc != '=' && nextc != ':') + if ((nextc != '=') & (nextc != ':')) syntax("'=' or ':' expected"); ep2 = newnode();