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.5 by greg, Sat Nov 21 21:42:42 1992 UTC vs.
Revision 2.9 by greg, Tue Mar 28 11:18:52 1995 UTC

# Line 42 | Line 42 | extern char  *ecalloc(), *emalloc(), *savestr(), *strc
42  
43   static double  dvalue();
44  
45 < long  eclock = -1;                      /* value storage timer */
45 > unsigned long  eclock = 0;              /* value storage timer */
46  
47   static char  context[MAXWORD+1];        /* current context path */
48  
# Line 189 | Line 189 | register char  *ctx;
189  
190      if (ctx == NULL)
191          return(context);                /* just asking */
192 +    while (*ctx == CNTXMARK)
193 +        ctx++;                          /* skip past marks */
194      if (!*ctx) {
195 <        context[0] = '\0';              /* clear context */
195 >        context[0] = '\0';              /* empty means clear context */
196          return(context);
197      }
198 <    cpp = context;                      /* else copy it (carefully!) */
199 <    if (*ctx != CNTXMARK)
200 <        *cpp++ = CNTXMARK;              /* make sure there's a mark */
199 <    do {
198 >    cpp = context;                      /* start context with mark */
199 >    *cpp++ = CNTXMARK;
200 >    do {                                /* carefully copy new context */
201          if (cpp >= context+MAXWORD)
202              break;                      /* just copy what we can */
203          if (isid(*ctx))
# Line 205 | Line 206 | register char  *ctx;
206              *cpp++ = '_'; ctx++;
207          }
208      } while (*ctx);
209 +    while (cpp[-1] == CNTXMARK)         /* cannot end in context mark */
210 +        cpp--;
211      *cpp = '\0';
212      return(context);
213   }
214  
215  
216   char *
217 + pushcontext(ctx)                /* push on another context */
218 + char  *ctx;
219 + {
220 +    extern char  *strncpy(), *strcpy();
221 +    char  oldcontext[MAXWORD+1];
222 +    register int  n;
223 +
224 +    strcpy(oldcontext, context);        /* save old context */
225 +    setcontext(ctx);                    /* set new context */
226 +    n = strlen(context);                /* tack on old */
227 +    if (n+strlen(oldcontext) > MAXWORD) {
228 +        strncpy(context+n, oldcontext, MAXWORD-n);
229 +        context[MAXWORD] = '\0';
230 +    } else
231 +        strcpy(context+n, oldcontext);
232 +    return(context);
233 + }
234 +
235 +
236 + char *
237 + popcontext()                    /* pop off top context */
238 + {
239 +    register char  *cp1, *cp2;
240 +
241 +    if (!context[0])                    /* nothing left to pop */
242 +        return(context);
243 +    cp2 = context;                      /* find mark */
244 +    while (*++cp2 && *cp2 != CNTXMARK)
245 +        ;
246 +    cp1 = context;                      /* copy tail to front */
247 +    while (*cp1++ = *cp2++)
248 +        ;
249 +    return(context);
250 + }
251 +
252 +
253 + char *
254   qualname(nam, lvl)              /* get qualified name */
255   register char  *nam;
256   int  lvl;
# Line 259 | Line 299 | toolong:
299   incontext(qn)                   /* is qualified name in current context? */
300   register char  *qn;
301   {
302 +    if (!context[0])                    /* global context accepts all */
303 +        return(1);
304      while (*qn && *qn != CNTXMARK)      /* find context mark */
305          qn++;
306      return(!strcmp(qn, context));
# Line 287 | Line 329 | int  lvl;
329                                  /* if context is global, clear all */
330      for (i = 0; i < NHASH; i++)
331          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
332 <            if (!context[0] || incontext(vp->name))
332 >            if (incontext(vp->name))
333                  if (lvl >= 2)
334                      dremove(vp->name);
335                  else
# Line 516 | Line 558 | getstatement()                 /* get next statement */
558          qname = qualname(dname(ep), 0);
559   #ifdef  REDEFW
560          if ((vdef = varlookup(qname)) != NULL)
561 <            if (vdef->def != NULL) {
561 >            if (vdef->def != NULL && epcmp(ep, vdef->def)) {
562                  wputs(qname);
563                  if (vdef->def->type == ':')
564                      wputs(": redefined constant expression\n");
# Line 598 | Line 640 | getdefn()                      /* A -> SYM = E1 */
640              ep1->sibling->type != NUM) {
641          ep1 = newnode();
642          ep1->type = TICK;
643 <        ep1->v.tick = -1;
643 >        ep1->v.tick = 0;
644          addekid(ep2, ep1);
645          ep1 = newnode();
646          ep1->type = NUM;
# Line 659 | Line 701 | EPNODE *d;
701      if (ep1->type == NUM)
702          return(ep1->v.num);                     /* return if number */
703      ep2 = ep1->sibling;                         /* check time */
704 <    if (ep2->v.tick < 0 || ep2->v.tick < eclock) {
705 <        ep2->v.tick = d->type == ':' ? 1L<<30 : eclock;
704 >    if (ep2->v.tick == 0 || ep2->v.tick < eclock) {
705 >        ep2->v.tick = d->type == ':' ? ~0L : eclock;
706          ep2 = ep2->sibling;
707          ep2->v.num = evalue(ep1);               /* needs new value */
708      } else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines