--- ray/src/common/caldefn.c 2012/07/29 22:10:45 2.25 +++ ray/src/common/caldefn.c 2022/03/12 17:21:10 2.31 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: caldefn.c,v 2.25 2012/07/29 22:10:45 greg Exp $"; +static const char RCSid[] = "$Id: caldefn.c,v 2.31 2022/03/12 17:21:10 greg Exp $"; #endif /* * Store variable definitions. @@ -27,8 +27,6 @@ static const char RCSid[] = "$Id: caldefn.c,v 2.25 201 #include "copyright.h" -#include -#include #include #include "rterror.h" @@ -142,6 +140,13 @@ varset( /* set a variable's value */ return; } } + if (ep1 != NULL && esupport&E_REDEFW) { + wputs(qname); + if (ep1->type == ':') + wputs(": reset constant expression\n"); + else + wputs(": reset expression\n"); + } /* hand build definition */ ep1 = newnode(); ep1->type = assign; @@ -191,13 +196,16 @@ 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); } @@ -632,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 != ')') @@ -697,7 +707,7 @@ getchan(void) /* A -> $N = E1 */ static double /* evaluate a variable */ -dvalue(char *name, EPNODE *d) +dvalue(char *name, EPNODE *d) { EPNODE *ep1, *ep2; @@ -709,6 +719,10 @@ dvalue(char *name, EPNODE *d) ep1 = d->v.kid->sibling; /* get expression */ if (ep1->type == NUM) return(ep1->v.num); /* return if number */ + if (esupport&E_RCONST && d->type == ':') { + wputs(name); + wputs(": assigned non-constant value\n"); + } ep2 = ep1->sibling; /* check time */ if (eclock >= MAXCLOCK) eclock = 1; /* wrap clock counter */