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.8 by greg, Fri Feb 17 18:34:42 1995 UTC vs.
Revision 2.11 by greg, Wed Feb 12 17:38:03 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1997 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 44 | Line 44 | static double  dvalue();
44  
45   unsigned long  eclock = 0;              /* value storage timer */
46  
47 < static char  context[MAXWORD+1];        /* current context path */
47 > #define  MAXCNTX        1023            /* maximum context length */
48  
49 + static char  context[MAXCNTX+1];        /* current context path */
50 +
51   static VARDEF  *hashtbl[NHASH];         /* definition list */
52   static int  htndx;                      /* index for */        
53   static VARDEF  *htpos;                  /* ...dfirst() and */
# Line 55 | Line 57 | static EPNODE  *outchan;
57   #endif
58  
59   #ifdef  FUNCTION
60 < EPNODE  *curfunc;
60 > EPNODE  *curfunc = NULL;
61   #define  dname(ep)      ((ep)->v.kid->type == SYM ? \
62                          (ep)->v.kid->v.name : \
63                          (ep)->v.kid->v.kid->v.name)
# Line 198 | Line 200 | register char  *ctx;
200      cpp = context;                      /* start context with mark */
201      *cpp++ = CNTXMARK;
202      do {                                /* carefully copy new context */
203 <        if (cpp >= context+MAXWORD)
203 >        if (cpp >= context+MAXCNTX)
204              break;                      /* just copy what we can */
205          if (isid(*ctx))
206              *cpp++ = *ctx++;
# Line 218 | Line 220 | pushcontext(ctx)               /* push on another context */
220   char  *ctx;
221   {
222      extern char  *strncpy(), *strcpy();
223 <    char  oldcontext[MAXWORD+1];
223 >    char  oldcontext[MAXCNTX+1];
224      register int  n;
225  
226      strcpy(oldcontext, context);        /* save old context */
227      setcontext(ctx);                    /* set new context */
228      n = strlen(context);                /* tack on old */
229 <    if (n+strlen(oldcontext) > MAXWORD) {
230 <        strncpy(context+n, oldcontext, MAXWORD-n);
231 <        context[MAXWORD] = '\0';
229 >    if (n+strlen(oldcontext) > MAXCNTX) {
230 >        strncpy(context+n, oldcontext, MAXCNTX-n);
231 >        context[MAXCNTX] = '\0';
232      } else
233          strcpy(context+n, oldcontext);
234      return(context);
# Line 299 | Line 301 | toolong:
301   incontext(qn)                   /* is qualified name in current context? */
302   register char  *qn;
303   {
304 +    if (!context[0])                    /* global context accepts all */
305 +        return(1);
306      while (*qn && *qn != CNTXMARK)      /* find context mark */
307          qn++;
308      return(!strcmp(qn, context));
# Line 327 | Line 331 | int  lvl;
331                                  /* if context is global, clear all */
332      for (i = 0; i < NHASH; i++)
333          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
334 <            if (!context[0] || incontext(vp->name))
334 >            if (incontext(vp->name))
335                  if (lvl >= 2)
336                      dremove(vp->name);
337                  else
# Line 618 | Line 622 | getdefn()                      /* A -> SYM = E1 */
622              syntax("')' expected");
623          scan();
624          curfunc = ep1;
625 <    } else
622 <        curfunc = NULL;
625 >    }
626   #endif
627  
628      if (nextc != '=' && nextc != ':')
# Line 644 | Line 647 | getdefn()                      /* A -> SYM = E1 */
647          ep1->type = NUM;
648          addekid(ep2, ep1);
649      }
650 +
651 + #ifdef  FUNCTION
652 +    curfunc = NULL;
653 + #endif
654  
655      return(ep2);
656   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines