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.3 by greg, Mon May 18 14:15:49 1992 UTC vs.
Revision 2.7 by greg, Sun Nov 22 17:29:46 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20  
21   #include  <errno.h>
22  
23 + #include  <math.h>
24 +
25   #include  "calcomp.h"
26  
27                                  /* bits in argument flag (better be right!) */
# Line 102 | Line 104 | int
104   fundefined(fname)               /* return # of arguments for function */
105   char  *fname;
106   {
107 <    LIBR  *lp;
107 >    register LIBR  *lp;
108      register VARDEF  *vp;
109  
110 <    if ((vp = varlookup(fname)) == NULL || vp->def == NULL
111 <                || vp->def->v.kid->type != FUNC)
110 <        if ((lp = liblookup(fname)) == NULL)
111 <            return(0);
112 <        else
113 <            return(lp->nargs);
114 <    else
110 >    if ((vp = varlookup(fname)) != NULL && vp->def != NULL
111 >                && vp->def->v.kid->type == FUNC)
112          return(nekids(vp->def->v.kid) - 1);
113 +    lp = vp != NULL ? vp->lib : liblookup(fname);
114 +    if (lp == NULL)
115 +        return(0);
116 +    return(lp->nargs);
117   }
118  
119  
# Line 153 | Line 154 | int  nargs;
154   int  assign;
155   double  (*fptr)();
156   {
157 +    int  oldlibsize = libsize;
158      register LIBR  *lp;
159  
160      if ((lp = liblookup(fname)) == NULL) {      /* insert */
# Line 185 | Line 187 | double  (*fptr)();
187          lp[0].atyp = assign;
188          lp[0].f = fptr;
189      }
190 <    libupdate(fname);                   /* relink library */
190 >    if (libsize != oldlibsize)
191 >        libupdate(fname);                       /* relink library */
192   }
193  
194  
# Line 337 | Line 340 | char  *fname;
340  
341  
342   #ifndef  VARIABLE
343 + static VARDEF  *varlist = NULL;         /* our list of dummy variables */
344 +
345 +
346   VARDEF *
347   varinsert(vname)                /* dummy variable insert */
348   char  *vname;
# Line 347 | Line 353 | char  *vname;
353      vp->name = savestr(vname);
354      vp->nlinks = 1;
355      vp->def = NULL;
356 <    vp->lib = NULL;
357 <    vp->next = NULL;
356 >    vp->lib = liblookup(vname);
357 >    vp->next = varlist;
358 >    varlist = vp;
359      return(vp);
360   }
361  
# Line 356 | Line 363 | char  *vname;
363   varfree(vp)                     /* free dummy variable */
364   register VARDEF  *vp;
365   {
366 +    register VARDEF  *vp2;
367 +
368 +    if (vp == varlist)
369 +        varlist = vp->next;
370 +    else {
371 +        for (vp2 = varlist; vp2->next != vp; vp2 = vp2->next)
372 +                ;
373 +        vp2->next = vp->next;
374 +    }
375      freestr(vp->name);
376      efree((char *)vp);
377   }
378 +
379 +
380 + libupdate(nm)                   /* update library */
381 + char  *nm;
382 + {
383 +    register VARDEF  *vp;
384 +
385 +    for (vp = varlist; vp != NULL; vp = vp->next)
386 +        vp->lib = liblookup(vp->name);
387 + }
388   #endif
389  
390  
# Line 446 | Line 472 | l_select()             /* return argument #(A1+1) */
472   static double
473   l_rand()                /* random function between 0 and 1 */
474   {
449    extern double  floor();
475      double  x;
476  
477      x = argument(1);
# Line 460 | Line 485 | l_rand()               /* random function between 0 and 1 */
485   static double
486   l_floor()               /* return largest integer not greater than arg1 */
487   {
463    extern double  floor();
464
488      return(floor(argument(1)));
489   }
490  
# Line 469 | Line 492 | l_floor()              /* return largest integer not greater than
492   static double
493   l_ceil()                /* return smallest integer not less than arg1 */
494   {
472    extern double  ceil();
473
495      return(ceil(argument(1)));
496   }
497  
# Line 479 | Line 500 | l_ceil()               /* return smallest integer not less than arg
500   static double
501   l_sqrt()
502   {
482    extern double  sqrt();
483
503      return(sqrt(argument(1)));
504   }
505  
# Line 488 | Line 507 | l_sqrt()
507   static double
508   l_sin()
509   {
491    extern double  sin();
492
510      return(sin(argument(1)));
511   }
512  
# Line 497 | Line 514 | l_sin()
514   static double
515   l_cos()
516   {
500    extern double  cos();
501
517      return(cos(argument(1)));
518   }
519  
# Line 506 | Line 521 | l_cos()
521   static double
522   l_tan()
523   {
509    extern double  tan();
510
524      return(tan(argument(1)));
525   }
526  
# Line 515 | Line 528 | l_tan()
528   static double
529   l_asin()
530   {
518    extern double  asin();
519
531      return(asin(argument(1)));
532   }
533  
# Line 524 | Line 535 | l_asin()
535   static double
536   l_acos()
537   {
527    extern double  acos();
528
538      return(acos(argument(1)));
539   }
540  
# Line 533 | Line 542 | l_acos()
542   static double
543   l_atan()
544   {
536    extern double  atan();
537
545      return(atan(argument(1)));
546   }
547  
# Line 542 | Line 549 | l_atan()
549   static double
550   l_atan2()
551   {
545    extern double  atan2();
546
552      return(atan2(argument(1), argument(2)));
553   }
554  
# Line 551 | Line 556 | l_atan2()
556   static double
557   l_exp()
558   {
554    extern double  exp();
555
559      return(exp(argument(1)));
560   }
561  
# Line 560 | Line 563 | l_exp()
563   static double
564   l_log()
565   {
563    extern double  log();
564
566      return(log(argument(1)));
567   }
568  
# Line 569 | Line 570 | l_log()
570   static double
571   l_log10()
572   {
572    extern double  log10();
573
573      return(log10(argument(1)));
574   }
575   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines