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

Comparing ray/src/common/calprnt.c (file contents):
Revision 2.8 by greg, Fri Feb 23 03:47:57 2024 UTC vs.
Revision 2.9 by greg, Sat Feb 24 19:00:23 2024 UTC

# Line 14 | Line 14 | static const char      RCSid[] = "$Id$";
14   #include  "calcomp.h"
15  
16  
17 < /* is child binary operation lower precedence than parent? */
17 > /* is child operation lower precedence than parent? */
18   static int
19 < lower_precedent_binop(int typ, EPNODE *ek)
19 > lower_precedent_op(int typ, EPNODE *ek)
20   {
21      if (ek == NULL)
22          return(0);
# Line 106 | Line 106 | eprint(                                /* print a parse tree */
106              break;
107  
108          case '+':
109        case '-':
109          case '*':
110 +        case '-':
111          case '/':
112          case '^':
113 <            if (lower_precedent_binop(ep->type, ep->v.kid)) {
113 >            if (lower_precedent_op(ep->type, ep->v.kid)) {
114                  fputc('(', fp);
115                  eprint(ep->v.kid, fp);
116                  fputc(')', fp);
117              } else
118                  eprint(ep->v.kid, fp);
119 <            if (ep->type != '^') {
120 <                fputc(' ', fp);
121 <                fputc(ep->type, fp);
122 <                fputc(' ', fp);
123 <            } else
124 <                fputc(ep->type, fp);
125 <            if (lower_precedent_binop(ep->type, ep->v.kid->sibling)) {
126 <                fputc('(', fp);
127 <                eprint(ep->v.kid->sibling, fp);
128 <                fputc(')', fp);
129 <            } else
130 <                eprint(ep->v.kid->sibling, fp);
119 >            for (ep1 = ep->v.kid->sibling; ep1 != NULL; ep1 = ep1->sibling) {
120 >                if (ep->type != '^') {
121 >                    fputc(' ', fp);
122 >                    fputc(ep->type, fp);
123 >                    fputc(' ', fp);
124 >                } else
125 >                    fputc(ep->type, fp);
126 >                if (lower_precedent_op(ep->type, ep1)) {
127 >                    fputc('(', fp);
128 >                    eprint(ep1, fp);
129 >                    fputc(')', fp);
130 >                } else
131 >                    eprint(ep1, fp);
132 >            }
133              break;
134  
135          default:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines