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

Comparing ray/src/common/calfunc.c (file contents):
Revision 2.2 by greg, Fri May 15 16:38:47 1992 UTC vs.
Revision 2.4 by greg, Thu May 21 10:29:32 1992 UTC

# Line 337 | Line 337 | char  *fname;
337  
338  
339   #ifndef  VARIABLE
340 + static VARDEF  *varlist = NULL;         /* our list of dummy variables */
341 +
342 +
343   VARDEF *
344   varinsert(vname)                /* dummy variable insert */
345   char  *vname;
# Line 347 | Line 350 | char  *vname;
350      vp->name = savestr(vname);
351      vp->nlinks = 1;
352      vp->def = NULL;
353 <    vp->lib = NULL;
354 <    vp->next = NULL;
353 >    vp->lib = liblookup(vname);
354 >    vp->next = varlist;
355 >    varlist = vp;
356      return(vp);
357   }
358  
# Line 356 | Line 360 | char  *vname;
360   varfree(vp)                     /* free dummy variable */
361   register VARDEF  *vp;
362   {
363 +    register VARDEF  *vp2;
364 +
365 +    if (vp == varlist)
366 +        varlist = vp->next;
367 +    else {
368 +        for (vp2 = varlist; vp2->next != vp; vp2 = vp2->next)
369 +                ;
370 +        vp2->next = vp->next;
371 +    }
372      freestr(vp->name);
373      efree((char *)vp);
374   }
375 +
376 +
377 + libupdate(nm)                   /* update library */
378 + char  *nm;
379 + {
380 +    register VARDEF  *vp;
381 +
382 +    for (vp = varlist; vp != NULL; vp = vp->next)
383 +        vp->lib = liblookup(vp->name);
384 + }
385   #endif
386  
387  
# Line 371 | Line 394 | register VARDEF  *vp;
394   static double
395   libfunc(fname, vp)                      /* execute library function */
396   char  *fname;
397 < register VARDEF  *vp;
397 > VARDEF  *vp;
398   {
399 <    VARDEF  dumdef;
399 >    register LIBR  *lp;
400      double  d;
401      int  lasterrno;
402  
403 <    if (vp == NULL) {
404 <        vp = &dumdef;
405 <        vp->lib = liblookup(fname);
406 <    }
407 <    if (vp->lib == NULL) {
403 >    if (vp != NULL)
404 >        lp = vp->lib;
405 >    else
406 >        lp = liblookup(fname);
407 >    if (lp == NULL) {
408          eputs(fname);
409          eputs(": undefined function\n");
410          quit(1);
411      }
412      lasterrno = errno;
413      errno = 0;
414 <    d = (*vp->lib->f)(vp->lib->fname);
414 >    d = (*lp->f)(lp->fname);
415   #ifdef  IEEE
416      if (errno == 0)
417          if (isnan(d))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines