--- ray/src/common/caldefn.c 2003/07/03 22:41:44 2.17 +++ ray/src/common/caldefn.c 2003/10/27 10:19:31 2.21 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: caldefn.c,v 2.17 2003/07/03 22:41:44 schorsch Exp $"; +static const char RCSid[] = "$Id: caldefn.c,v 2.21 2003/10/27 10:19:31 schorsch Exp $"; #endif /* * Store variable definitions. @@ -28,11 +28,11 @@ static const char RCSid[] = "$Id: caldefn.c,v 2.17 200 #include "copyright.h" #include - #include - #include +#include "rterror.h" +#include "rtmisc.h" #include "calcomp.h" #ifndef NHASH @@ -43,7 +43,7 @@ static const char RCSid[] = "$Id: caldefn.c,v 2.17 200 #define newnode() (EPNODE *)ecalloc(1, sizeof(EPNODE)) -static double dvalue(); +static double dvalue(char *name, EPNODE *d); #define MAXCLOCK (1L<<31) /* clock wrap value */ @@ -260,7 +260,7 @@ popcontext(void) /* pop off top context */ while (*++cp2 && *cp2 != CNTXMARK) ; cp1 = context; /* copy tail to front */ - while (*cp1++ = *cp2++) + while ( (*cp1++ = *cp2++) ) ; return(context); } @@ -350,11 +350,12 @@ dcleanup( /* clear definitions (0->vars,1->output,2-> /* if context is global, clear all */ for (i = 0; i < NHASH; i++) for (vp = hashtbl[i]; vp != NULL; vp = vp->next) - if (incontext(vp->name)) + if (incontext(vp->name)) { if (lvl >= 2) dremove(vp->name); else dclear(vp->name); + } if (lvl >= 1) { for (ep = outchan; ep != NULL; ep = ep->sibling) epfree(ep); @@ -572,7 +573,7 @@ getstatement(void) /* get next statement */ } else { /* ordinary definition */ ep = getdefn(); qname = qualname(dname(ep), 0); - if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) + if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) { if (vdef->def != NULL && epcmp(ep, vdef->def)) { wputs(qname); if (vdef->def->type == ':') @@ -583,6 +584,7 @@ getstatement(void) /* get next statement */ wputs(qname); wputs(": definition hides library function\n"); } + } if (ep->type == ':') dremove(qname); else @@ -689,11 +691,8 @@ getchan(void) /* A -> $N = E1 */ */ -static double -dvalue( /* evaluate a variable */ -char *name, -EPNODE *d -) +static double /* evaluate a variable */ +dvalue(char *name, EPNODE *d) { register EPNODE *ep1, *ep2; @@ -709,7 +708,7 @@ EPNODE *d if (eclock >= MAXCLOCK) eclock = 1; /* wrap clock counter */ if (ep2->v.tick < MAXCLOCK && - ep2->v.tick == 0 | ep2->v.tick != eclock) { + (ep2->v.tick == 0) | (ep2->v.tick != eclock)) { ep2->v.tick = d->type == ':' ? MAXCLOCK : eclock; ep2 = ep2->sibling; ep2->v.num = evalue(ep1); /* needs new value */