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.26 by greg, Thu Jul 24 15:41:13 2014 UTC vs.
Revision 2.33 by greg, Fri Apr 8 23:32:25 2022 UTC

# Line 27 | Line 27 | static const char      RCSid[] = "$Id$";
27  
28   #include "copyright.h"
29  
30 #include  <stdio.h>
31 #include  <string.h>
30   #include  <ctype.h>
31  
32   #include  "rterror.h"
# Line 198 | Line 196 | dremove(                       /* delete all definitions of name */
196  
197  
198   int
199 < vardefined(     /* return non-zero if variable defined */
199 > vardefined(     /* return '=' or ':' if variable/constant defined */
200          char  *name
201   )
202   {
203 <    EPNODE  *dp;
203 >    EPNODE  *dp = dlookup(name);
204  
205 <    return((dp = dlookup(name)) != NULL && dp->v.kid->type == SYM);
205 >    if (dp == NULL || dp->v.kid->type != SYM)
206 >        return(0);
207 >
208 >    return(dp->type);
209   }
210  
211  
212   char *
213 < setcontext(                     /* set a new context path */
213 > calcontext(                     /* set a new context path */
214          char  *ctx
215   )
216   {
# Line 250 | Line 251 | pushcontext(           /* push on another context */
251      int  n;
252  
253      strcpy(oldcontext, context);        /* save old context */
254 <    setcontext(ctx);                    /* set new context */
254 >    calcontext(ctx);                    /* set new context */
255      n = strlen(context);                /* tack on old */
256      if (n+strlen(oldcontext) > MAXCNTX) {
257          strncpy(context+n, oldcontext, MAXCNTX-n);
# Line 442 | Line 443 | libupdate(                     /* update library links */
443                                          /* if fn is NULL then relink all */
444      for (i = 0; i < NHASH; i++)
445          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
446 <            if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name))
446 >            if ((vp->lib != NULL) | (fn == NULL) || !strcmp(fn, vp->name))
447                  vp->lib = liblookup(vp->name);
448   }
449  
# Line 620 | Line 621 | getdefn(void)
621   {
622      EPNODE  *ep1, *ep2;
623  
624 <    if (!isalpha(nextc) && nextc != CNTXMARK)
624 >    if (!isalpha(nextc) & (nextc != CNTXMARK))
625          syntax("illegal variable name");
626  
627      ep1 = newnode();
# Line 639 | Line 640 | getdefn(void)
640              ep2 = newnode();
641              ep2->type = SYM;
642              ep2->v.name = savestr(getname());
643 +            if (strchr(ep2->v.name, CNTXMARK) != NULL)
644 +                syntax("illegal parameter name");
645              addekid(ep1, ep2);
646          } while (nextc == ',');
647          if (nextc != ')')
# Line 647 | Line 650 | getdefn(void)
650          curfunc = ep1;
651      }
652  
653 <    if (nextc != '=' && nextc != ':')
653 >    if ((nextc != '=') & (nextc != ':'))
654          syntax("'=' or ':' expected");
655  
656      ep2 = newnode();
# Line 704 | Line 707 | getchan(void)                  /* A -> $N = E1 */
707  
708  
709   static double                   /* evaluate a variable */
710 < dvalue(char  *name, EPNODE      *d)
710 > dvalue(char *name, EPNODE *d)
711   {
712      EPNODE  *ep1, *ep2;
713      
# Line 716 | Line 719 | dvalue(char  *name, EPNODE     *d)
719      ep1 = d->v.kid->sibling;                    /* get expression */
720      if (ep1->type == NUM)
721          return(ep1->v.num);                     /* return if number */
722 +    if (esupport&E_RCONST && d->type == ':') {
723 +        wputs(name);
724 +        wputs(": assigned non-constant value\n");
725 +    }
726      ep2 = ep1->sibling;                         /* check time */
727      if (eclock >= MAXCLOCK)
728          eclock = 1;                             /* wrap clock counter */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines