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

Comparing ray/src/common/caldefn.c (file contents):
Revision 2.16 by schorsch, Sat Jun 7 12:50:20 2003 UTC vs.
Revision 2.21 by schorsch, Mon Oct 27 10:19:31 2003 UTC

# Line 28 | Line 28 | static const char      RCSid[] = "$Id$";
28   #include "copyright.h"
29  
30   #include  <stdio.h>
31
31   #include  <string.h>
33
32   #include  <ctype.h>
33  
34 + #include  "rterror.h"
35 + #include  "rtmisc.h"
36   #include  "calcomp.h"
37  
38   #ifndef  NHASH
# Line 43 | Line 43 | static const char      RCSid[] = "$Id$";
43  
44   #define  newnode()      (EPNODE *)ecalloc(1, sizeof(EPNODE))
45  
46 < static double  dvalue();
46 > static double  dvalue(char  *name, EPNODE *d);
47  
48   #define  MAXCLOCK       (1L<<31)        /* clock wrap value */
49  
# Line 260 | Line 260 | popcontext(void)                       /* pop off top context */
260      while (*++cp2 && *cp2 != CNTXMARK)
261          ;
262      cp1 = context;                      /* copy tail to front */
263 <    while (*cp1++ = *cp2++)
263 >    while ( (*cp1++ = *cp2++) )
264          ;
265      return(context);
266   }
# Line 272 | Line 272 | qualname(              /* get qualified name */
272          int  lvl
273   )
274   {
275 <    static char  nambuf[MAXWORD+1];
275 >    static char  nambuf[RMAXWORD+1];
276      register char  *cp = nambuf, *cpp;
277                                  /* check for explicit local */
278      if (*nam == CNTXMARK)
# Line 284 | Line 284 | qualname(              /* get qualified name */
284          return(lvl > 0 ? NULL : nam);
285                                  /* copy name to static buffer */
286      while (*nam) {
287 <        if (cp >= nambuf+MAXWORD)
287 >        if (cp >= nambuf+RMAXWORD)
288                  goto toolong;
289          *cp++ = *nam++;
290      }
# Line 303 | Line 303 | qualname(              /* get qualified name */
303              ;
304      }
305      while (*cpp) {              /* copy context to static buffer */
306 <        if (cp >= nambuf+MAXWORD)
306 >        if (cp >= nambuf+RMAXWORD)
307              goto toolong;
308          *cp++ = *cpp++;
309      }
# Line 350 | Line 350 | dcleanup(              /* clear definitions (0->vars,1->output,2->
350                                  /* if context is global, clear all */
351      for (i = 0; i < NHASH; i++)
352          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
353 <            if (incontext(vp->name))
353 >            if (incontext(vp->name)) {
354                  if (lvl >= 2)
355                      dremove(vp->name);
356                  else
357                      dclear(vp->name);
358 +            }
359      if (lvl >= 1) {
360          for (ep = outchan; ep != NULL; ep = ep->sibling)
361              epfree(ep);
# Line 572 | Line 573 | getstatement(void)                     /* get next statement */
573      } else {                            /* ordinary definition */
574          ep = getdefn();
575          qname = qualname(dname(ep), 0);
576 <        if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL)
576 >        if (esupport&E_REDEFW && (vdef = varlookup(qname)) != NULL) {
577              if (vdef->def != NULL && epcmp(ep, vdef->def)) {
578                  wputs(qname);
579                  if (vdef->def->type == ':')
# Line 583 | Line 584 | getstatement(void)                     /* get next statement */
584                  wputs(qname);
585                  wputs(": definition hides library function\n");
586              }
587 +        }
588          if (ep->type == ':')
589              dremove(qname);
590          else
# Line 689 | Line 691 | getchan(void)                  /* A -> $N = E1 */
691   */
692  
693  
694 < static double
695 < dvalue(                 /* evaluate a variable */
694 < char  *name,
695 < EPNODE  *d
696 < )
694 > static double                   /* evaluate a variable */
695 > dvalue(char  *name, EPNODE      *d)
696   {
697      register EPNODE  *ep1, *ep2;
698      
# Line 709 | Line 708 | EPNODE *d
708      if (eclock >= MAXCLOCK)
709          eclock = 1;                             /* wrap clock counter */
710      if (ep2->v.tick < MAXCLOCK &&
711 <                ep2->v.tick == 0 | ep2->v.tick != eclock) {
711 >                (ep2->v.tick == 0) | (ep2->v.tick != eclock)) {
712          ep2->v.tick = d->type == ':' ? MAXCLOCK : eclock;
713          ep2 = ep2->sibling;
714          ep2->v.num = evalue(ep1);               /* needs new value */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines