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

Comparing ray/src/common/calexpr.c (file contents):
Revision 2.47 by greg, Sun Feb 25 04:11:10 2024 UTC vs.
Revision 2.49 by greg, Mon Feb 26 18:16:35 2024 UTC

# Line 37 | Line 37 | static const char      RCSid[] = "$Id$";
37  
38   #define  envalue(ep)    ((ep)->type==NUM ? (ep)->v.num : evalue(ep))
39  
40 < static double  euminus(EPNODE *), eargument(EPNODE *), enumber(EPNODE *);
40 > static double  euminus(EPNODE *), enumber(EPNODE *);
41   static double  echannel(EPNODE *);
42   static double  eadd(EPNODE *), esubtr(EPNODE *),
43                 emult(EPNODE *), edivi(EPNODE *),
# Line 218 | Line 218 | epflatten(                     /* flatten hierarchies for '+', '*' */
218   {
219      EPNODE      *ep;
220  
221 <    if (epar->nkids < 0) {
222 <        eputs("Cannot flatten EPNODE array\n");
223 <        quit(1);
224 <    }
221 >    if (epar->nkids < 0)        /* can't handle array allocations */
222 >        return;
223 >
224      for (ep = epar->v.kid; ep != NULL; ep = ep->sibling)
225 <        while (ep->type == epar->type) {
225 >        while (ep->type == epar->type && ep->nkids > 0) {
226              EPNODE      *ep1 = ep->v.kid;
227              while (ep1->sibling != NULL)
228                  ep1 = ep1->sibling;
229              ep1->sibling = ep->sibling;
230 <            epar->nkids += nekids(ep) - 1;
230 >            epar->nkids += ep->nkids - 1;
231              ep1 = ep->v.kid;
232              *ep = *ep1;
233              efree(ep1);         /* not epfree()! */
# Line 267 | Line 266 | epoptimize(                    /* flatten operations, lists -> arrays *
266  
267                                  /* the following used to be a switch */
268   static double
270 eargument(
271    EPNODE      *ep
272 )
273 {
274    return(argument(ep->v.chan));
275 }
276
277 static double
269   enumber(
270      EPNODE      *ep
271   )
# Line 347 | Line 338 | edivi(
338   )
339   {
340      EPNODE  *ep1 = ep->v.kid;
341 <    EPNODE  *ep2 = ep1->sibling;
351 <    double  d;
341 >    double  den = evalue(ep1->sibling);
342  
343 <    d = evalue(ep2);
354 <    if (d == 0.0) {
343 >    if (den == 0.0) {
344          wputs("Division by zero\n");
345          errno = ERANGE;
346          return(0.0);
347      }
348 <    return(envalue(ep1) / d);
348 >    return(envalue(ep1) / den);
349   }
350  
351   static double

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines