ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/calexpr.c
(Generate patch)

Comparing ray/src/common/calexpr.c (file contents):
Revision 1.12 by greg, Thu Aug 8 11:22:04 1991 UTC vs.
Revision 2.5 by greg, Tue May 19 20:21:58 1992 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1986 Regents of the University of California */
1 > /* Copyright (c) 1991 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 32 | Line 32 | static char SCCSid[] = "$SunId$ LBL";
32  
33   #define  isdecimal(c)   (isdigit(c) || (c) == '.')
34  
35 < extern double  atof(), pow();
35 > #ifndef atof
36 > extern double  atof();
37 > #endif
38 > extern double  pow();
39   extern char  *fgets(), *savestr();
40   extern char  *emalloc(), *ecalloc();
41   extern EPNODE  *curfunc;
# Line 133 | Line 136 | register EPNODE  *epar;
136          case VAR:
137              varfree(epar->v.ln);
138              break;
136 #endif
139              
140          case SYM:
141              freestr(epar->v.name);
142              break;
143 + #endif
144  
145          case NUM:
146          case CHAN:
# Line 323 | Line 326 | int  ln;
326   }
327  
328  
329 + getscanpos(fnp, lnp, spp, fpp)  /* return current scan position */
330 + char  **fnp;
331 + int  *lnp;
332 + char  **spp;
333 + FILE  **fpp;
334 + {
335 +    if (fnp != NULL) *fnp = infile;
336 +    if (lnp != NULL) *lnp = lineno;
337 +    if (spp != NULL) *spp = linbuf+linepos;
338 +    if (fpp != NULL) *fpp = infp;
339 + }
340 +
341 +
342   int
343   scan()                          /* scan next character, return literal next */
344   {
# Line 421 | Line 437 | EPNODE  *ekid;
437   }
438  
439  
440 + #if  defined(VARIABLE) || defined(FUNCTION)
441   char *
442   getname()                       /* scan an identifier */
443   {
# Line 431 | Line 448 | getname()                      /* scan an identifier */
448      for (i = 0; i < MAXWORD && isid(lnext); i++, lnext = scan())
449          str[i] = lnext;
450      str[i] = '\0';
451 +    while (isid(lnext))         /* skip rest of name */
452 +        lnext = scan();
453  
454      return(str);
455   }
456 + #endif
457  
458  
459   int
# Line 571 | Line 591 | getE4()                                /* E4 -> ADDOP E5 */
591                  ep2->v.num = -ep2->v.num;
592                  return(ep2);
593          }
594 +        if (ep2->type == UMINUS) {      /* don't generate -(-E5) */
595 +            efree((char *)ep2);
596 +            return(ep2->v.kid);
597 +        }
598          ep1 = newnode();
599          ep1->type = UMINUS;
600          addekid(ep1, ep2);
# Line 591 | Line 615 | getE5()                                /* E5 -> (E1) */
615                                  /*       ARG */
616   {
617      int  i;
618 +    char  *nam;
619      register EPNODE  *ep1, *ep2;
620  
621      if (nextc == '(') {
# Line 613 | Line 638 | getE5()                                /* E5 -> (E1) */
638   #endif
639  
640   #if  defined(VARIABLE) || defined(FUNCTION)
641 <    if (isalpha(nextc)) {
642 <        ep1 = newnode();
618 <        ep1->type = VAR;
619 <        ep1->v.ln = varinsert(getname());
620 <
641 >    if (isalpha(nextc) || nextc == CNTXMARK) {
642 >        nam = getname();
643   #if  defined(VARIABLE) && defined(FUNCTION)
644 +        ep1 = NULL;
645          if (curfunc != NULL)
646              for (i = 1, ep2 = curfunc->v.kid->sibling;
647                                  ep2 != NULL; i++, ep2 = ep2->sibling)
648 <                if (!strcmp(ep2->v.name, ep1->v.ln->name)) {
626 <                    epfree(ep1);
648 >                if (!strcmp(ep2->v.name, nam)) {
649                      ep1 = newnode();
650                      ep1->type = ARG;
651                      ep1->v.chan = i;
652                      break;
653                  }
654 +        if (ep1 == NULL)
655   #endif
656 +        {
657 +            ep1 = newnode();
658 +            ep1->type = VAR;
659 +            ep1->v.ln = varinsert(nam);
660 +        }
661   #ifdef  FUNCTION
662          if (nextc == '(') {
663              ep2 = newnode();
# Line 727 | Line 755 | register EPNODE  *ep;
755  
756      if (ep->type != VAR)
757          return(0);
758 <    dp = ep->v.ln->def;
759 <    if (dp != NULL && dp->type != ':')
760 <        return(0);
761 <    if ((dp == NULL || dp->v.kid->type != FUNC)
762 <            && ((lp = liblookup(ep->v.ln->name)) == NULL
735 <                    || lp->atyp != ':'))
736 <        return(0);
737 <    return(1);
758 >    if ((dp = ep->v.ln->def) != NULL && dp->v.kid->type == FUNC)
759 >        return(dp->type == ':');
760 >    if ((lp = ep->v.ln->lib) != NULL)
761 >        return(lp->atyp == ':');
762 >    return(0);
763   }
764   #endif
765   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines