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.44 by greg, Sat Feb 24 19:00:23 2024 UTC vs.
Revision 2.47 by greg, Sun Feb 25 04:11:10 2024 UTC

# Line 211 | Line 211 | epfree(                        /* free a parse tree */
211   }
212  
213  
214 < void
214 > static void
215   epflatten(                      /* flatten hierarchies for '+', '*' */
216          EPNODE *epar
217   )
218   {
219      EPNODE      *ep;
220  
221 <    if (epar->nkids < 0)        /* don't really handle this properly */
222 <        epar->nkids *= -1;
223 <
221 >    if (epar->nkids < 0) {
222 >        eputs("Cannot flatten EPNODE array\n");
223 >        quit(1);
224 >    }
225      for (ep = epar->v.kid; ep != NULL; ep = ep->sibling)
226          while (ep->type == epar->type) {
227              EPNODE      *ep1 = ep->v.kid;
# Line 236 | Line 237 | epflatten(                     /* flatten hierarchies for '+', '*' */
237  
238  
239   void
240 < epoptimize(                     /* flatten operations and lists -> arrays */
240 > epoptimize(                     /* flatten operations, lists -> arrays */
241          EPNODE  *epar
242   )
243   {
244      EPNODE      *ep;
245  
246 <   if ((epar->type == '+') | (epar->type == '*'))
247 <        epflatten(epar);        /* commutative & associative */
246 >    if ((epar->type == '+') | (epar->type == '*'))
247 >        epflatten(epar);        /* flatten associative operations */
248  
249 <   if (epar->nkids)             /* do children if any */
249 >    if (epar->nkids)            /* do children if any */
250          for (ep = epar->v.kid; ep != NULL; ep = ep->sibling)
251              epoptimize(ep);
252  
# Line 349 | Line 350 | edivi(
350      EPNODE  *ep2 = ep1->sibling;
351      double  d;
352  
353 <    d = envalue(ep2);
353 >    d = evalue(ep2);
354      if (d == 0.0) {
355          wputs("Division by zero\n");
356          errno = ERANGE;
# Line 562 | Line 563 | addekid(                       /* add a child to ep */
563      EPNODE      *ek
564   )
565   {
566 <    if (ep->nkids < 0)          /* we don't really handle this properly */
567 <        ep->nkids *= -1;
566 >    if (ep->nkids < 0) {
567 >        eputs("Cannot add kid to EPNODE array\n");
568 >        quit(1);
569 >    }
570      ep->nkids++;
571      if (ep->v.kid == NULL)
572          ep->v.kid = ek;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines