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.4 by greg, Mon Sep 21 12:01:44 1992 UTC vs.
Revision 2.8 by greg, Fri Feb 17 18:34:42 1995 UTC

# Line 34 | Line 34 | static char SCCSid[] = "$SunId$ LBL";
34   #define  NHASH          521             /* hash size (a prime!) */
35   #endif
36  
37 + #define  hash(s)        (shash(s)%NHASH)
38 +
39   #define  newnode()      (EPNODE *)ecalloc(1, sizeof(EPNODE))
40  
41   extern char  *ecalloc(), *emalloc(), *savestr(), *strcpy();
42  
41 static int  hash();
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 516 | Line 556 | getstatement()                 /* get next statement */
556          qname = qualname(dname(ep), 0);
557   #ifdef  REDEFW
558          if ((vdef = varlookup(qname)) != NULL)
559 <            if (vdef->def != NULL) {
559 >            if (vdef->def != NULL && epcmp(ep, vdef->def)) {
560                  wputs(qname);
561                  if (vdef->def->type == ':')
562                      wputs(": redefined constant expression\n");
# Line 598 | Line 638 | getdefn()                      /* A -> SYM = E1 */
638              ep1->sibling->type != NUM) {
639          ep1 = newnode();
640          ep1->type = TICK;
641 <        ep1->v.tick = -1;
641 >        ep1->v.tick = 0;
642          addekid(ep2, ep1);
643          ep1 = newnode();
644          ep1->type = NUM;
# Line 659 | Line 699 | EPNODE *d;
699      if (ep1->type == NUM)
700          return(ep1->v.num);                     /* return if number */
701      ep2 = ep1->sibling;                         /* check time */
702 <    if (ep2->v.tick < 0 || ep2->v.tick < eclock) {
703 <        ep2->v.tick = d->type == ':' ? 1L<<30 : eclock;
702 >    if (ep2->v.tick == 0 || ep2->v.tick < eclock) {
703 >        ep2->v.tick = d->type == ':' ? ~0L : eclock;
704          ep2 = ep2->sibling;
705          ep2->v.num = evalue(ep1);               /* needs new value */
706      } else
707          ep2 = ep2->sibling;                     /* else reuse old value */
708  
709      return(ep2->v.num);
670 }
671
672
673 static int
674 hash(s)                         /* hash a string */
675 register char  *s;
676 {
677    register int  rval = 0;
678
679    while (*s)
680        rval += *s++;
681    
682    return(rval % NHASH);
710   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines