--- ray/src/common/calexpr.c 1991/08/08 13:40:09 1.14 +++ ray/src/common/calexpr.c 1992/05/19 20:21:58 2.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -32,7 +32,10 @@ static char SCCSid[] = "$SunId$ LBL"; #define isdecimal(c) (isdigit(c) || (c) == '.') -extern double atof(), pow(); +#ifndef atof +extern double atof(); +#endif +extern double pow(); extern char *fgets(), *savestr(); extern char *emalloc(), *ecalloc(); extern EPNODE *curfunc; @@ -133,11 +136,11 @@ register EPNODE *epar; case VAR: varfree(epar->v.ln); break; -#endif case SYM: freestr(epar->v.name); break; +#endif case NUM: case CHAN: @@ -434,6 +437,7 @@ EPNODE *ekid; } +#if defined(VARIABLE) || defined(FUNCTION) char * getname() /* scan an identifier */ { @@ -444,9 +448,12 @@ getname() /* scan an identifier */ for (i = 0; i < MAXWORD && isid(lnext); i++, lnext = scan()) str[i] = lnext; str[i] = '\0'; + while (isid(lnext)) /* skip rest of name */ + lnext = scan(); return(str); } +#endif int @@ -584,6 +591,10 @@ getE4() /* E4 -> ADDOP E5 */ ep2->v.num = -ep2->v.num; return(ep2); } + if (ep2->type == UMINUS) { /* don't generate -(-E5) */ + efree((char *)ep2); + return(ep2->v.kid); + } ep1 = newnode(); ep1->type = UMINUS; addekid(ep1, ep2); @@ -627,7 +638,7 @@ getE5() /* E5 -> (E1) */ #endif #if defined(VARIABLE) || defined(FUNCTION) - if (isalpha(nextc)) { + if (isalpha(nextc) || nextc == CNTXMARK) { nam = getname(); #if defined(VARIABLE) && defined(FUNCTION) ep1 = NULL; @@ -744,14 +755,11 @@ register EPNODE *ep; if (ep->type != VAR) return(0); - dp = ep->v.ln->def; - if (dp != NULL && dp->type != ':') - return(0); - if ((dp == NULL || dp->v.kid->type != FUNC) - && ((lp = liblookup(ep->v.ln->name)) == NULL - || lp->atyp != ':')) - return(0); - return(1); + if ((dp = ep->v.ln->def) != NULL && dp->v.kid->type == FUNC) + return(dp->type == ':'); + if ((lp = ep->v.ln->lib) != NULL) + return(lp->atyp == ':'); + return(0); } #endif #endif