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.21 by greg, Mon Jun 10 13:56:52 2019 UTC vs.
Revision 2.23 by greg, Tue Jun 11 22:13:50 2019 UTC

# Line 71 | Line 71 | static LIBR  library[MAXLIB] = {
71      { "tan", 1, ':', l_tan },
72   };
73  
74 < static int  libsize = 16;
74 > static int  libsize = 18;
75  
76   #define  resolve(ep)    ((ep)->type==VAR?(ep)->v.ln:argf((ep)->v.chan))
77  
# Line 390 | Line 390 | l_if(char *nm)         /* if(cond, then, else) conditional ex
390   static double
391   l_select(char *nm)      /* return argument #(A1+1) */
392   {
393 <        int  n;
393 >        int     narg = nargum();
394 >        double  a1 = argument(1);
395 >        int  n = (int)(a1 + .5);
396  
397 <        n = (int)(argument(1) + .5);
396 <        if (n == 0)
397 <                return(nargum()-1);
398 <        if (n < 1 || n > nargum()-1) {
397 >        if (a1 < -.5 || n >= narg) {
398                  errno = EDOM;
399                  return(0.0);
400          }
401 +        if (!n)         /* asking max index? */
402 +                return(narg-1);
403          return(argument(n+1));
404   }
405  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines