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.23 by greg, Tue Jun 11 22:13:50 2019 UTC vs.
Revision 2.29 by greg, Sun Feb 25 18:36:27 2024 UTC

# Line 22 | Line 22 | static const char      RCSid[] = "$Id$";
22  
23                                  /* bits in argument flag (better be right!) */
24   #define  AFLAGSIZ       (8*sizeof(unsigned long))
25 < #define  ALISTSIZ       8       /* maximum saved argument list */
25 > #define  ALISTSIZ       10      /* maximum saved argument list */
26  
27   typedef struct activation {
28      char  *name;                /* function name */
# Line 150 | Line 150 | funset(                                /* set a library function */
150          if (cp == fname) return;
151      }
152      if ((lp = liblookup(fname)) == NULL) {      /* insert */
153 +        if (fptr == NULL)
154 +                return;                         /* nothing! */
155          if (libsize >= MAXLIB) {
156              eputs("Too many library functons!\n");
157              quit(1);
# Line 201 | Line 203 | argument(int n)                        /* return nth argument for active fu
203      EPNODE  *ep = NULL;
204      double  aval;
205  
204    if (!n)                                     /* asking for # arguments? */
205        return((double)nargum());
206
206      if (!actp | (--n < 0)) {
207          eputs("Bad call to argument!\n");
208          quit(1);
# Line 356 | Line 355 | libfunc(                               /* execute library function */
355              errno = ERANGE;
356      }
357   #endif
358 <    if (errno == EDOM || errno == ERANGE) {
358 >    if ((errno == EDOM) | (errno == ERANGE)) {
359          wputs(fname);
360          if (errno == EDOM)
361                  wputs(": domain error\n");
# Line 394 | Line 393 | l_select(char *nm)     /* return argument #(A1+1) */
393          double  a1 = argument(1);
394          int  n = (int)(a1 + .5);
395  
396 <        if (a1 < -.5 || n >= narg) {
396 >        if ((a1 < -.5) | (n >= narg)) {
397                  errno = EDOM;
398                  return(0.0);
399          }
# Line 408 | Line 407 | static double
407   l_max(char *nm)         /* general maximum function */
408   {
409          int  n = nargum();
410 <        int  i = 1;
412 <        int  vmax = argument(1);
410 >        double  vmax = argument(1);
411  
412 <        while (i++ < n) {
413 <                double  v = argument(i);
412 >        while (n > 1) {
413 >                double  v = argument(n--);
414                  if (vmax < v)
415                          vmax = v;
416          }
# Line 424 | Line 422 | static double
422   l_min(char *nm)         /* general minimum function */
423   {
424          int  n = nargum();
425 <        int  i = 1;
428 <        int  vmin = argument(1);
425 >        double  vmin = argument(1);
426  
427 <        while (i++ < n) {
428 <                double  v = argument(i);
427 >        while (n > 1) {
428 >                double  v = argument(n--);
429                  if (vmin > v)
430                          vmin = v;
431          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines