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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines