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.12 by greg, Sat Feb 22 02:07:21 2003 UTC vs.
Revision 2.18 by schorsch, Thu Jul 17 09:21:29 2003 UTC

# Line 25 | Line 25 | static const char      RCSid[] = "$Id$";
25   *  2/19/03     Eliminated conditional compiles in favor of esupport extern.
26   */
27  
28 < /* ====================================================================
29 < * The Radiance Software License, Version 1.0
30 < *
31 < * Copyright (c) 1990 - 2002 The Regents of the University of California,
32 < * through Lawrence Berkeley National Laboratory.   All rights reserved.
33 < *
34 < * Redistribution and use in source and binary forms, with or without
35 < * modification, are permitted provided that the following conditions
36 < * are met:
37 < *
38 < * 1. Redistributions of source code must retain the above copyright
39 < *         notice, this list of conditions and the following disclaimer.
40 < *
41 < * 2. Redistributions in binary form must reproduce the above copyright
42 < *       notice, this list of conditions and the following disclaimer in
43 < *       the documentation and/or other materials provided with the
44 < *       distribution.
45 < *
46 < * 3. The end-user documentation included with the redistribution,
47 < *           if any, must include the following acknowledgment:
48 < *             "This product includes Radiance software
49 < *                 (http://radsite.lbl.gov/)
50 < *                 developed by the Lawrence Berkeley National Laboratory
51 < *               (http://www.lbl.gov/)."
52 < *       Alternately, this acknowledgment may appear in the software itself,
53 < *       if and wherever such third-party acknowledgments normally appear.
54 < *
55 < * 4. The names "Radiance," "Lawrence Berkeley National Laboratory"
56 < *       and "The Regents of the University of California" must
57 < *       not be used to endorse or promote products derived from this
58 < *       software without prior written permission. For written
59 < *       permission, please contact [email protected].
60 < *
61 < * 5. Products derived from this software may not be called "Radiance",
62 < *       nor may "Radiance" appear in their name, without prior written
63 < *       permission of Lawrence Berkeley National Laboratory.
64 < *
65 < * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
66 < * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
67 < * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
68 < * DISCLAIMED.   IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR
69 < * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
70 < * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
71 < * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
72 < * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
73 < * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
74 < * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
75 < * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
76 < * SUCH DAMAGE.
77 < * ====================================================================
78 < *
79 < * This software consists of voluntary contributions made by many
80 < * individuals on behalf of Lawrence Berkeley National Laboratory.   For more
81 < * information on Lawrence Berkeley National Laboratory, please see
82 < * <http://www.lbl.gov/>.
83 < */
28 > #include "copyright.h"
29  
30   #include  <stdio.h>
86
31   #include  <string.h>
88
32   #include  <ctype.h>
33  
34 + #include  "rterror.h"
35   #include  "calcomp.h"
36  
37   #ifndef  NHASH
# Line 98 | Line 42 | static const char      RCSid[] = "$Id$";
42  
43   #define  newnode()      (EPNODE *)ecalloc(1, sizeof(EPNODE))
44  
45 < static double  dvalue();
45 > static double  dvalue(char  *name, EPNODE *d);
46  
47   #define  MAXCLOCK       (1L<<31)        /* clock wrap value */
48  
# Line 121 | Line 65 | EPNODE *curfunc = NULL;
65  
66  
67   void
68 < fcompile(fname)                 /* get definitions from a file */
69 < char  *fname;
68 > fcompile(                       /* get definitions from a file */
69 >        char  *fname
70 > )
71   {
72      FILE  *fp;
73  
# Line 142 | Line 87 | char  *fname;
87  
88  
89   void
90 < scompile(str, fn, ln)           /* get definitions from a string */
91 < char  *str;
92 < char  *fn;
93 < int  ln;
90 > scompile(               /* get definitions from a string */
91 >        char  *str,
92 >        char  *fn,
93 >        int  ln
94 > )
95   {
96      initstr(str, fn, ln);
97      while (nextc != EOF)
# Line 154 | Line 100 | int  ln;
100  
101  
102   double
103 < varvalue(vname)                 /* return a variable's value */
104 < char  *vname;
103 > varvalue(                       /* return a variable's value */
104 >        char  *vname
105 > )
106   {
107      return(dvalue(vname, dlookup(vname)));
108   }
109  
110  
111   double
112 < evariable(ep)                   /* evaluate a variable */
113 < EPNODE  *ep;
112 > evariable(                      /* evaluate a variable */
113 >        EPNODE  *ep
114 > )
115   {
116      register VARDEF  *dp = ep->v.ln;
117  
# Line 172 | Line 120 | EPNODE *ep;
120  
121  
122   void
123 < varset(vname, assign, val)      /* set a variable's value */
124 < char  *vname;
125 < int  assign;
126 < double  val;
123 > varset(         /* set a variable's value */
124 >        char  *vname,
125 >        int  assign,
126 >        double  val
127 > )
128   {
129      char  *qname;
130      register EPNODE  *ep1, *ep2;
# Line 207 | Line 156 | double val;
156  
157  
158   void
159 < dclear(name)                    /* delete variable definitions of name */
160 < char  *name;
159 > dclear(                 /* delete variable definitions of name */
160 >        char  *name
161 > )
162   {
163      register EPNODE  *ep;
164  
# Line 223 | Line 173 | char  *name;
173  
174  
175   void
176 < dremove(name)                   /* delete all definitions of name */
177 < char  *name;
176 > dremove(                        /* delete all definitions of name */
177 >        char  *name
178 > )
179   {
180      register EPNODE  *ep;
181  
# Line 234 | Line 185 | char  *name;
185  
186  
187   int
188 < vardefined(name)        /* return non-zero if variable defined */
189 < char  *name;
188 > vardefined(     /* return non-zero if variable defined */
189 >        char  *name
190 > )
191   {
192      register EPNODE  *dp;
193  
# Line 244 | Line 196 | char  *name;
196  
197  
198   char *
199 < setcontext(ctx)                 /* set a new context path */
200 < register char  *ctx;
199 > setcontext(                     /* set a new context path */
200 >        register char  *ctx
201 > )
202   {
203      register char  *cpp;
204  
# Line 276 | Line 229 | register char  *ctx;
229  
230  
231   char *
232 < pushcontext(ctx)                /* push on another context */
233 < char  *ctx;
232 > pushcontext(            /* push on another context */
233 >        char  *ctx
234 > )
235   {
282    extern char  *strncpy(), *strcpy();
236      char  oldcontext[MAXCNTX+1];
237      register int  n;
238  
# Line 296 | Line 249 | char  *ctx;
249  
250  
251   char *
252 < popcontext()                    /* pop off top context */
252 > popcontext(void)                        /* pop off top context */
253   {
254      register char  *cp1, *cp2;
255  
# Line 313 | Line 266 | popcontext()                   /* pop off top context */
266  
267  
268   char *
269 < qualname(nam, lvl)              /* get qualified name */
270 < register char  *nam;
271 < int  lvl;
269 > qualname(               /* get qualified name */
270 >        register char  *nam,
271 >        int  lvl
272 > )
273   {
274 <    static char  nambuf[MAXWORD+1];
274 >    static char  nambuf[RMAXWORD+1];
275      register char  *cp = nambuf, *cpp;
276                                  /* check for explicit local */
277      if (*nam == CNTXMARK)
# Line 329 | Line 283 | int  lvl;
283          return(lvl > 0 ? NULL : nam);
284                                  /* copy name to static buffer */
285      while (*nam) {
286 <        if (cp >= nambuf+MAXWORD)
286 >        if (cp >= nambuf+RMAXWORD)
287                  goto toolong;
288          *cp++ = *nam++;
289      }
# Line 348 | Line 302 | int  lvl;
302              ;
303      }
304      while (*cpp) {              /* copy context to static buffer */
305 <        if (cp >= nambuf+MAXWORD)
305 >        if (cp >= nambuf+RMAXWORD)
306              goto toolong;
307          *cp++ = *cpp++;
308      }
# Line 359 | Line 313 | toolong:
313  
314  
315   int
316 < incontext(qn)                   /* is qualified name in current context? */
317 < register char  *qn;
316 > incontext(                      /* is qualified name in current context? */
317 >        register char  *qn
318 > )
319   {
320      if (!context[0])                    /* global context accepts all */
321          return(1);
# Line 371 | Line 326 | register char  *qn;
326  
327  
328   void
329 < chanout(cs)                     /* set output channels */
330 < int  (*cs)();
329 > chanout(                        /* set output channels */
330 >        void  (*cs)(int n, double v)
331 > )
332   {
333      register EPNODE  *ep;
334  
# Line 383 | Line 339 | int  (*cs)();
339  
340  
341   void
342 < dcleanup(lvl)           /* clear definitions (0->vars,1->output,2->consts) */
343 < int  lvl;
342 > dcleanup(               /* clear definitions (0->vars,1->output,2->consts) */
343 >        int  lvl
344 > )
345   {
346      register int  i;
347      register VARDEF  *vp;
# Line 406 | Line 363 | int  lvl;
363  
364  
365   EPNODE *
366 < dlookup(name)                   /* look up a definition */
367 < char  *name;
366 > dlookup(                        /* look up a definition */
367 >        char  *name
368 > )
369   {
370      register VARDEF  *vp;
371      
# Line 418 | Line 376 | char  *name;
376  
377  
378   VARDEF *
379 < varlookup(name)                 /* look up a variable */
380 < char  *name;
379 > varlookup(                      /* look up a variable */
380 >        char  *name
381 > )
382   {
383      int  lvl = 0;
384      register char  *qname;
# Line 434 | Line 393 | char  *name;
393  
394  
395   VARDEF *
396 < varinsert(name)                 /* get a link to a variable */
397 < char  *name;
396 > varinsert(                      /* get a link to a variable */
397 >        char  *name
398 > )
399   {
400      register VARDEF  *vp;
401      int  hv;
# Line 459 | Line 419 | char  *name;
419  
420  
421   void
422 < libupdate(fn)                   /* update library links */
423 < char  *fn;
422 > libupdate(                      /* update library links */
423 >        char  *fn
424 > )
425   {
426      register int  i;
427      register VARDEF  *vp;
# Line 473 | Line 434 | char  *fn;
434  
435  
436   void
437 < varfree(ln)                             /* release link to variable */
438 < register VARDEF  *ln;
437 > varfree(                                /* release link to variable */
438 >        register VARDEF  *ln
439 > )
440   {
441      register VARDEF  *vp;
442      int  hv;
# Line 497 | Line 459 | register VARDEF         *ln;
459  
460  
461   EPNODE *
462 < dfirst()                        /* return pointer to first definition */
462 > dfirst(void)                    /* return pointer to first definition */
463   {
464      htndx = 0;
465      htpos = NULL;
# Line 507 | Line 469 | dfirst()                       /* return pointer to first definition */
469  
470  
471   EPNODE *
472 < dnext()                         /* return pointer to next definition */
472 > dnext(void)                             /* return pointer to next definition */
473   {
474      register EPNODE  *ep;
475      register char  *nm;
# Line 530 | Line 492 | dnext()                                /* return pointer to next definition */
492  
493  
494   EPNODE *
495 < dpop(name)                      /* pop a definition */
496 < char  *name;
495 > dpop(                   /* pop a definition */
496 >        char  *name
497 > )
498   {
499      register VARDEF  *vp;
500      register EPNODE  *dp;
# Line 546 | Line 509 | char  *name;
509  
510  
511   void
512 < dpush(nm, ep)                   /* push on a definition */
513 < char  *nm;
514 < register EPNODE  *ep;
512 > dpush(                  /* push on a definition */
513 >        char  *nm,
514 >        register EPNODE  *ep
515 > )
516   {
517      register VARDEF  *vp;
518  
# Line 559 | Line 523 | register EPNODE         *ep;
523  
524  
525   void
526 < addchan(sp)                     /* add an output channel assignment */
527 < EPNODE  *sp;
526 > addchan(                        /* add an output channel assignment */
527 >        EPNODE  *sp
528 > )
529   {
530      int  ch = sp->v.kid->v.chan;
531      register EPNODE  *ep, *epl;
# Line 589 | Line 554 | EPNODE *sp;
554  
555  
556   void
557 < getstatement()                  /* get next statement */
557 > getstatement(void)                      /* get next statement */
558   {
559      register EPNODE  *ep;
560      char  *qname;
# Line 632 | Line 597 | getstatement()                 /* get next statement */
597  
598  
599   EPNODE *
600 < getdefn()                       /* A -> SYM = E1 */
601 <                                /*      SYM : E1 */
602 <                                /*      FUNC(SYM,..) = E1 */
603 <                                /*      FUNC(SYM,..) : E1 */
600 > getdefn(void)
601 >        /* A -> SYM = E1 */
602 >        /*      SYM : E1 */
603 >        /*      FUNC(SYM,..) = E1 */
604 >        /*      FUNC(SYM,..) : E1 */
605   {
606      register EPNODE  *ep1, *ep2;
607  
# Line 691 | Line 657 | getdefn()                      /* A -> SYM = E1 */
657  
658  
659   EPNODE *
660 < getchan()                       /* A -> $N = E1 */
660 > getchan(void)                   /* A -> $N = E1 */
661   {
662      register EPNODE  *ep1, *ep2;
663  
# Line 722 | Line 688 | getchan()                      /* A -> $N = E1 */
688   */
689  
690  
691 < static double
692 < dvalue(name, d)                 /* evaluate a variable */
727 < char  *name;
728 < EPNODE  *d;
691 > static double                   /* evaluate a variable */
692 > dvalue(char  *name, EPNODE      *d)
693   {
694      register EPNODE  *ep1, *ep2;
695      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines