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.4 by greg, Thu May 21 10:29:32 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 469 | Line 472 | l_select()             /* return argument #(A1+1) */
472   static double
473   l_rand()                /* random function between 0 and 1 */
474   {
472    extern double  floor();
475      double  x;
476  
477      x = argument(1);
# Line 483 | Line 485 | l_rand()               /* random function between 0 and 1 */
485   static double
486   l_floor()               /* return largest integer not greater than arg1 */
487   {
486    extern double  floor();
487
488      return(floor(argument(1)));
489   }
490  
# Line 492 | Line 492 | l_floor()              /* return largest integer not greater than
492   static double
493   l_ceil()                /* return smallest integer not less than arg1 */
494   {
495    extern double  ceil();
496
495      return(ceil(argument(1)));
496   }
497  
# Line 502 | Line 500 | l_ceil()               /* return smallest integer not less than arg
500   static double
501   l_sqrt()
502   {
505    extern double  sqrt();
506
503      return(sqrt(argument(1)));
504   }
505  
# Line 511 | Line 507 | l_sqrt()
507   static double
508   l_sin()
509   {
514    extern double  sin();
515
510      return(sin(argument(1)));
511   }
512  
# Line 520 | Line 514 | l_sin()
514   static double
515   l_cos()
516   {
523    extern double  cos();
524
517      return(cos(argument(1)));
518   }
519  
# Line 529 | Line 521 | l_cos()
521   static double
522   l_tan()
523   {
532    extern double  tan();
533
524      return(tan(argument(1)));
525   }
526  
# Line 538 | Line 528 | l_tan()
528   static double
529   l_asin()
530   {
541    extern double  asin();
542
531      return(asin(argument(1)));
532   }
533  
# Line 547 | Line 535 | l_asin()
535   static double
536   l_acos()
537   {
550    extern double  acos();
551
538      return(acos(argument(1)));
539   }
540  
# Line 556 | Line 542 | l_acos()
542   static double
543   l_atan()
544   {
559    extern double  atan();
560
545      return(atan(argument(1)));
546   }
547  
# Line 565 | Line 549 | l_atan()
549   static double
550   l_atan2()
551   {
568    extern double  atan2();
569
552      return(atan2(argument(1), argument(2)));
553   }
554  
# Line 574 | Line 556 | l_atan2()
556   static double
557   l_exp()
558   {
577    extern double  exp();
578
559      return(exp(argument(1)));
560   }
561  
# Line 583 | Line 563 | l_exp()
563   static double
564   l_log()
565   {
586    extern double  log();
587
566      return(log(argument(1)));
567   }
568  
# Line 592 | Line 570 | l_log()
570   static double
571   l_log10()
572   {
595    extern double  log10();
596
573      return(log10(argument(1)));
574   }
575   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines