--- ray/src/common/caldefn.c 1995/02/17 18:34:42 2.8 +++ ray/src/common/caldefn.c 1997/02/12 17:38:03 2.11 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1997 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -44,8 +44,10 @@ static double dvalue(); unsigned long eclock = 0; /* value storage timer */ -static char context[MAXWORD+1]; /* current context path */ +#define MAXCNTX 1023 /* maximum context length */ +static char context[MAXCNTX+1]; /* current context path */ + static VARDEF *hashtbl[NHASH]; /* definition list */ static int htndx; /* index for */ static VARDEF *htpos; /* ...dfirst() and */ @@ -55,7 +57,7 @@ static EPNODE *outchan; #endif #ifdef FUNCTION -EPNODE *curfunc; +EPNODE *curfunc = NULL; #define dname(ep) ((ep)->v.kid->type == SYM ? \ (ep)->v.kid->v.name : \ (ep)->v.kid->v.kid->v.name) @@ -198,7 +200,7 @@ register char *ctx; cpp = context; /* start context with mark */ *cpp++ = CNTXMARK; do { /* carefully copy new context */ - if (cpp >= context+MAXWORD) + if (cpp >= context+MAXCNTX) break; /* just copy what we can */ if (isid(*ctx)) *cpp++ = *ctx++; @@ -218,15 +220,15 @@ pushcontext(ctx) /* push on another context */ char *ctx; { extern char *strncpy(), *strcpy(); - char oldcontext[MAXWORD+1]; + char oldcontext[MAXCNTX+1]; register int n; strcpy(oldcontext, context); /* save old context */ setcontext(ctx); /* set new context */ n = strlen(context); /* tack on old */ - if (n+strlen(oldcontext) > MAXWORD) { - strncpy(context+n, oldcontext, MAXWORD-n); - context[MAXWORD] = '\0'; + if (n+strlen(oldcontext) > MAXCNTX) { + strncpy(context+n, oldcontext, MAXCNTX-n); + context[MAXCNTX] = '\0'; } else strcpy(context+n, oldcontext); return(context); @@ -299,6 +301,8 @@ toolong: incontext(qn) /* is qualified name in current context? */ register char *qn; { + if (!context[0]) /* global context accepts all */ + return(1); while (*qn && *qn != CNTXMARK) /* find context mark */ qn++; return(!strcmp(qn, context)); @@ -327,7 +331,7 @@ int lvl; /* if context is global, clear all */ for (i = 0; i < NHASH; i++) for (vp = hashtbl[i]; vp != NULL; vp = vp->next) - if (!context[0] || incontext(vp->name)) + if (incontext(vp->name)) if (lvl >= 2) dremove(vp->name); else @@ -618,8 +622,7 @@ getdefn() /* A -> SYM = E1 */ syntax("')' expected"); scan(); curfunc = ep1; - } else - curfunc = NULL; + } #endif if (nextc != '=' && nextc != ':') @@ -644,6 +647,10 @@ getdefn() /* A -> SYM = E1 */ ep1->type = NUM; addekid(ep2, ep1); } + +#ifdef FUNCTION + curfunc = NULL; +#endif return(ep2); }