--- ray/src/common/caldefn.c 1991/08/14 08:27:56 1.18 +++ ray/src/common/caldefn.c 1992/08/10 16:20:43 2.3 @@ -38,6 +38,8 @@ static char SCCSid[] = "$SunId$ LBL"; extern char *ecalloc(), *savestr(), *strcpy(); +static int hash(); + static double dvalue(); long eclock = -1; /* value storage timer */ @@ -258,7 +260,7 @@ incontext(qn) /* is qualified name in current contex register char *qn; { while (*qn && *qn != CNTXMARK) /* find context mark */ - ; + qn++; return(!strcmp(qn, context)); } @@ -333,32 +335,45 @@ varinsert(name) /* get a link to a variable */ char *name; { register VARDEF *vp; - LIBR *libp; int hv; if ((vp = varlookup(name)) != NULL) { vp->nlinks++; return(vp); } + vp = (VARDEF *)emalloc(sizeof(VARDEF)); #ifdef FUNCTION - libp = liblookup(name); + vp->lib = liblookup(name); #else - libp = NULL; + vp->lib = NULL; #endif - if (libp == NULL) /* if name not in library */ + if (vp->lib == NULL) /* if name not in library */ name = qualname(name, 0); /* use fully qualified version */ hv = hash(name); - vp = (VARDEF *)emalloc(sizeof(VARDEF)); vp->name = savestr(name); vp->nlinks = 1; vp->def = NULL; - vp->lib = libp; vp->next = hashtbl[hv]; hashtbl[hv] = vp; return(vp); } +#ifdef FUNCTION +libupdate(fn) /* update library links */ +char *fn; +{ + register int i; + register VARDEF *vp; + /* 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)) + vp->lib = liblookup(vp->name); +} +#endif + + varfree(ln) /* release link to variable */ register VARDEF *ln; { @@ -398,14 +413,16 @@ EPNODE * dnext() /* return pointer to next definition */ { register EPNODE *ep; + register char *nm; while (htndx < NHASH) { if (htpos == NULL) htpos = hashtbl[htndx++]; while (htpos != NULL) { ep = htpos->def; + nm = htpos->name; htpos = htpos->next; - if (ep != NULL) + if (ep != NULL && incontext(nm)) return(ep); } }