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.25 by greg, Sun Jul 29 22:10:45 2012 UTC vs.
Revision 2.34 by greg, Tue Feb 7 20:28:16 2023 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 80 | Line 78 | fcompile(                      /* get definitions from a file */
78          eputs(": cannot open\n");
79          quit(1);
80      }
81 <    initfile(fp, fname, 0);
81 > #ifdef getc_unlocked                    /* avoid stupid semaphores */
82 >    flockfile(fp);
83 > #endif
84 >   initfile(fp, fname, 0);
85      while (nextc != EOF)
86          getstatement();
87      if (fname != NULL)
88          fclose(fp);
89 + #ifdef getc_unlocked
90 +    else
91 +        funlockfile(fp);
92 + #endif
93   }
94  
95  
# Line 142 | Line 147 | varset(                /* set a variable's value */
147              return;
148          }
149      }
150 +    if (ep1 != NULL && esupport&E_REDEFW) {
151 +        wputs(qname);
152 +        if (ep1->type == ':')
153 +            wputs(": reset constant expression\n");
154 +        else
155 +            wputs(": reset expression\n");
156 +    }
157                                          /* hand build definition */
158      ep1 = newnode();
159      ep1->type = assign;
# Line 191 | Line 203 | dremove(                       /* delete all definitions of name */
203  
204  
205   int
206 < vardefined(     /* return non-zero if variable defined */
206 > vardefined(     /* return '=' or ':' if variable/constant defined */
207          char  *name
208   )
209   {
210 <    EPNODE  *dp;
210 >    EPNODE  *dp = dlookup(name);
211  
212 <    return((dp = dlookup(name)) != NULL && dp->v.kid->type == SYM);
212 >    if (dp == NULL || dp->v.kid->type != SYM)
213 >        return(0);
214 >
215 >    return(dp->type);
216   }
217  
218  
219   char *
220 < setcontext(                     /* set a new context path */
220 > calcontext(                     /* set a new context path */
221          char  *ctx
222   )
223   {
# Line 243 | Line 258 | pushcontext(           /* push on another context */
258      int  n;
259  
260      strcpy(oldcontext, context);        /* save old context */
261 <    setcontext(ctx);                    /* set new context */
261 >    calcontext(ctx);                    /* set new context */
262      n = strlen(context);                /* tack on old */
263      if (n+strlen(oldcontext) > MAXCNTX) {
264          strncpy(context+n, oldcontext, MAXCNTX-n);
# Line 435 | Line 450 | libupdate(                     /* update library links */
450                                          /* if fn is NULL then relink all */
451      for (i = 0; i < NHASH; i++)
452          for (vp = hashtbl[i]; vp != NULL; vp = vp->next)
453 <            if (vp->lib != NULL || fn == NULL || !strcmp(fn, vp->name))
453 >            if ((vp->lib != NULL) | (fn == NULL) || !strcmp(fn, vp->name))
454                  vp->lib = liblookup(vp->name);
455   }
456  
# Line 613 | Line 628 | getdefn(void)
628   {
629      EPNODE  *ep1, *ep2;
630  
631 <    if (!isalpha(nextc) && nextc != CNTXMARK)
631 >    if (!isalpha(nextc) & (nextc != CNTXMARK))
632          syntax("illegal variable name");
633  
634      ep1 = newnode();
# Line 632 | Line 647 | getdefn(void)
647              ep2 = newnode();
648              ep2->type = SYM;
649              ep2->v.name = savestr(getname());
650 +            if (strchr(ep2->v.name, CNTXMARK) != NULL)
651 +                syntax("illegal parameter name");
652              addekid(ep1, ep2);
653          } while (nextc == ',');
654          if (nextc != ')')
# Line 640 | Line 657 | getdefn(void)
657          curfunc = ep1;
658      }
659  
660 <    if (nextc != '=' && nextc != ':')
660 >    if ((nextc != '=') & (nextc != ':'))
661          syntax("'=' or ':' expected");
662  
663      ep2 = newnode();
# Line 697 | Line 714 | getchan(void)                  /* A -> $N = E1 */
714  
715  
716   static double                   /* evaluate a variable */
717 < dvalue(char  *name, EPNODE      *d)
717 > dvalue(char *name, EPNODE *d)
718   {
719      EPNODE  *ep1, *ep2;
720      
# Line 709 | Line 726 | dvalue(char  *name, EPNODE     *d)
726      ep1 = d->v.kid->sibling;                    /* get expression */
727      if (ep1->type == NUM)
728          return(ep1->v.num);                     /* return if number */
729 +    if (esupport&E_RCONST && d->type == ':') {
730 +        wputs(name);
731 +        wputs(": assigned non-constant value\n");
732 +    }
733      ep2 = ep1->sibling;                         /* check time */
734      if (eclock >= MAXCLOCK)
735          eclock = 1;                             /* wrap clock counter */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines