ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/caldefn.c
(Generate patch)

Comparing ray/src/common/caldefn.c (file contents):
Revision 1.18 by greg, Wed Aug 14 08:27:56 1991 UTC vs.
Revision 2.3 by greg, Mon Aug 10 16:20:43 1992 UTC

# Line 38 | Line 38 | static char SCCSid[] = "$SunId$ LBL";
38  
39   extern char  *ecalloc(), *savestr(), *strcpy();
40  
41 + static int  hash();
42 +
43   static double  dvalue();
44  
45   long  eclock = -1;                      /* value storage timer */
# Line 258 | Line 260 | incontext(qn)                  /* is qualified name in current contex
260   register char  *qn;
261   {
262      while (*qn && *qn != CNTXMARK)      /* find context mark */
263 <        ;
263 >        qn++;
264      return(!strcmp(qn, context));
265   }
266  
# Line 333 | Line 335 | varinsert(name)                        /* get a link to a variable */
335   char  *name;
336   {
337      register VARDEF  *vp;
336    LIBR  *libp;
338      int  hv;
339      
340      if ((vp = varlookup(name)) != NULL) {
341          vp->nlinks++;
342          return(vp);
343      }
344 +    vp = (VARDEF *)emalloc(sizeof(VARDEF));
345   #ifdef  FUNCTION
346 <    libp = liblookup(name);
346 >    vp->lib = liblookup(name);
347   #else
348 <    libp = NULL;
348 >    vp->lib = NULL;
349   #endif
350 <    if (libp == NULL)                   /* if name not in library */
350 >    if (vp->lib == NULL)                /* if name not in library */
351          name = qualname(name, 0);       /* use fully qualified version */
352      hv = hash(name);
351    vp = (VARDEF *)emalloc(sizeof(VARDEF));
353      vp->name = savestr(name);
354      vp->nlinks = 1;
355      vp->def = NULL;
355    vp->lib = libp;
356      vp->next = hashtbl[hv];
357      hashtbl[hv] = vp;
358      return(vp);
359   }
360  
361  
362 + #ifdef  FUNCTION
363 + libupdate(fn)                   /* update library links */
364 + char  *fn;
365 + {
366 +    register int  i;
367 +    register VARDEF  *vp;
368 +                                        /* if fn is NULL then relink all */
369 +    for (i = 0; i < NHASH; i++)
370 +        for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
371 +            if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name))
372 +                vp->lib = liblookup(vp->name);
373 + }
374 + #endif
375 +
376 +
377   varfree(ln)                             /* release link to variable */
378   register VARDEF  *ln;
379   {
# Line 398 | Line 413 | EPNODE *
413   dnext()                         /* return pointer to next definition */
414   {
415      register EPNODE  *ep;
416 +    register char  *nm;
417  
418      while (htndx < NHASH) {
419          if (htpos == NULL)
420                  htpos = hashtbl[htndx++];
421          while (htpos != NULL) {
422              ep = htpos->def;
423 +            nm = htpos->name;
424              htpos = htpos->next;
425 <            if (ep != NULL)
425 >            if (ep != NULL && incontext(nm))
426                  return(ep);
427          }
428      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines