--- ray/src/common/caldefn.c 2020/04/02 18:00:34 2.28 +++ ray/src/common/caldefn.c 2022/03/30 16:00:56 2.32 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: caldefn.c,v 2.28 2020/04/02 18:00:34 greg Exp $"; +static const char RCSid[] = "$Id: caldefn.c,v 2.32 2022/03/30 16:00:56 greg Exp $"; #endif /* * Store variable definitions. @@ -196,18 +196,21 @@ dremove( /* delete all definitions of name */ int -vardefined( /* return non-zero if variable defined */ +vardefined( /* return '=' or ':' if variable/constant defined */ char *name ) { - EPNODE *dp; + EPNODE *dp = dlookup(name); - return((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 ) { @@ -248,7 +251,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); @@ -637,6 +640,8 @@ getdefn(void) ep2 = newnode(); ep2->type = SYM; ep2->v.name = savestr(getname()); + if (strchr(ep2->v.name, CNTXMARK) != NULL) + syntax("illegal parameter name"); addekid(ep1, ep2); } while (nextc == ','); if (nextc != ')')