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.17 by schorsch, Thu Jul 3 22:41:44 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>
31  
# Line 121 | Line 66 | EPNODE *curfunc = NULL;
66  
67  
68   void
69 < fcompile(fname)                 /* get definitions from a file */
70 < char  *fname;
69 > fcompile(                       /* get definitions from a file */
70 >        char  *fname
71 > )
72   {
73      FILE  *fp;
74  
# Line 142 | Line 88 | char  *fname;
88  
89  
90   void
91 < scompile(str, fn, ln)           /* get definitions from a string */
92 < char  *str;
93 < char  *fn;
94 < int  ln;
91 > scompile(               /* get definitions from a string */
92 >        char  *str,
93 >        char  *fn,
94 >        int  ln
95 > )
96   {
97      initstr(str, fn, ln);
98      while (nextc != EOF)
# Line 154 | Line 101 | int  ln;
101  
102  
103   double
104 < varvalue(vname)                 /* return a variable's value */
105 < char  *vname;
104 > varvalue(                       /* return a variable's value */
105 >        char  *vname
106 > )
107   {
108      return(dvalue(vname, dlookup(vname)));
109   }
110  
111  
112   double
113 < evariable(ep)                   /* evaluate a variable */
114 < EPNODE  *ep;
113 > evariable(                      /* evaluate a variable */
114 >        EPNODE  *ep
115 > )
116   {
117      register VARDEF  *dp = ep->v.ln;
118  
# Line 172 | Line 121 | EPNODE *ep;
121  
122  
123   void
124 < varset(vname, assign, val)      /* set a variable's value */
125 < char  *vname;
126 < int  assign;
127 < double  val;
124 > varset(         /* set a variable's value */
125 >        char  *vname,
126 >        int  assign,
127 >        double  val
128 > )
129   {
130      char  *qname;
131      register EPNODE  *ep1, *ep2;
# Line 207 | Line 157 | double val;
157  
158  
159   void
160 < dclear(name)                    /* delete variable definitions of name */
161 < char  *name;
160 > dclear(                 /* delete variable definitions of name */
161 >        char  *name
162 > )
163   {
164      register EPNODE  *ep;
165  
# Line 223 | Line 174 | char  *name;
174  
175  
176   void
177 < dremove(name)                   /* delete all definitions of name */
178 < char  *name;
177 > dremove(                        /* delete all definitions of name */
178 >        char  *name
179 > )
180   {
181      register EPNODE  *ep;
182  
# Line 234 | Line 186 | char  *name;
186  
187  
188   int
189 < vardefined(name)        /* return non-zero if variable defined */
190 < char  *name;
189 > vardefined(     /* return non-zero if variable defined */
190 >        char  *name
191 > )
192   {
193      register EPNODE  *dp;
194  
# Line 244 | Line 197 | char  *name;
197  
198  
199   char *
200 < setcontext(ctx)                 /* set a new context path */
201 < register char  *ctx;
200 > setcontext(                     /* set a new context path */
201 >        register char  *ctx
202 > )
203   {
204      register char  *cpp;
205  
# Line 276 | Line 230 | register char  *ctx;
230  
231  
232   char *
233 < pushcontext(ctx)                /* push on another context */
234 < char  *ctx;
233 > pushcontext(            /* push on another context */
234 >        char  *ctx
235 > )
236   {
282    extern char  *strncpy(), *strcpy();
237      char  oldcontext[MAXCNTX+1];
238      register int  n;
239  
# Line 296 | Line 250 | char  *ctx;
250  
251  
252   char *
253 < popcontext()                    /* pop off top context */
253 > popcontext(void)                        /* pop off top context */
254   {
255      register char  *cp1, *cp2;
256  
# Line 313 | Line 267 | popcontext()                   /* pop off top context */
267  
268  
269   char *
270 < qualname(nam, lvl)              /* get qualified name */
271 < register char  *nam;
272 < int  lvl;
270 > qualname(               /* get qualified name */
271 >        register char  *nam,
272 >        int  lvl
273 > )
274   {
275 <    static char  nambuf[MAXWORD+1];
275 >    static char  nambuf[RMAXWORD+1];
276      register char  *cp = nambuf, *cpp;
277                                  /* check for explicit local */
278      if (*nam == CNTXMARK)
# Line 329 | Line 284 | int  lvl;
284          return(lvl > 0 ? NULL : nam);
285                                  /* copy name to static buffer */
286      while (*nam) {
287 <        if (cp >= nambuf+MAXWORD)
287 >        if (cp >= nambuf+RMAXWORD)
288                  goto toolong;
289          *cp++ = *nam++;
290      }
# Line 348 | Line 303 | int  lvl;
303              ;
304      }
305      while (*cpp) {              /* copy context to static buffer */
306 <        if (cp >= nambuf+MAXWORD)
306 >        if (cp >= nambuf+RMAXWORD)
307              goto toolong;
308          *cp++ = *cpp++;
309      }
# Line 359 | Line 314 | toolong:
314  
315  
316   int
317 < incontext(qn)                   /* is qualified name in current context? */
318 < register char  *qn;
317 > incontext(                      /* is qualified name in current context? */
318 >        register char  *qn
319 > )
320   {
321      if (!context[0])                    /* global context accepts all */
322          return(1);
# Line 371 | Line 327 | register char  *qn;
327  
328  
329   void
330 < chanout(cs)                     /* set output channels */
331 < int  (*cs)();
330 > chanout(                        /* set output channels */
331 >        void  (*cs)(int n, double v)
332 > )
333   {
334      register EPNODE  *ep;
335  
# Line 383 | Line 340 | int  (*cs)();
340  
341  
342   void
343 < dcleanup(lvl)           /* clear definitions (0->vars,1->output,2->consts) */
344 < int  lvl;
343 > dcleanup(               /* clear definitions (0->vars,1->output,2->consts) */
344 >        int  lvl
345 > )
346   {
347      register int  i;
348      register VARDEF  *vp;
# Line 406 | Line 364 | int  lvl;
364  
365  
366   EPNODE *
367 < dlookup(name)                   /* look up a definition */
368 < char  *name;
367 > dlookup(                        /* look up a definition */
368 >        char  *name
369 > )
370   {
371      register VARDEF  *vp;
372      
# Line 418 | Line 377 | char  *name;
377  
378  
379   VARDEF *
380 < varlookup(name)                 /* look up a variable */
381 < char  *name;
380 > varlookup(                      /* look up a variable */
381 >        char  *name
382 > )
383   {
384      int  lvl = 0;
385      register char  *qname;
# Line 434 | Line 394 | char  *name;
394  
395  
396   VARDEF *
397 < varinsert(name)                 /* get a link to a variable */
398 < char  *name;
397 > varinsert(                      /* get a link to a variable */
398 >        char  *name
399 > )
400   {
401      register VARDEF  *vp;
402      int  hv;
# Line 459 | Line 420 | char  *name;
420  
421  
422   void
423 < libupdate(fn)                   /* update library links */
424 < char  *fn;
423 > libupdate(                      /* update library links */
424 >        char  *fn
425 > )
426   {
427      register int  i;
428      register VARDEF  *vp;
# Line 473 | Line 435 | char  *fn;
435  
436  
437   void
438 < varfree(ln)                             /* release link to variable */
439 < register VARDEF  *ln;
438 > varfree(                                /* release link to variable */
439 >        register VARDEF  *ln
440 > )
441   {
442      register VARDEF  *vp;
443      int  hv;
# Line 497 | Line 460 | register VARDEF         *ln;
460  
461  
462   EPNODE *
463 < dfirst()                        /* return pointer to first definition */
463 > dfirst(void)                    /* return pointer to first definition */
464   {
465      htndx = 0;
466      htpos = NULL;
# Line 507 | Line 470 | dfirst()                       /* return pointer to first definition */
470  
471  
472   EPNODE *
473 < dnext()                         /* return pointer to next definition */
473 > dnext(void)                             /* return pointer to next definition */
474   {
475      register EPNODE  *ep;
476      register char  *nm;
# Line 530 | Line 493 | dnext()                                /* return pointer to next definition */
493  
494  
495   EPNODE *
496 < dpop(name)                      /* pop a definition */
497 < char  *name;
496 > dpop(                   /* pop a definition */
497 >        char  *name
498 > )
499   {
500      register VARDEF  *vp;
501      register EPNODE  *dp;
# Line 546 | Line 510 | char  *name;
510  
511  
512   void
513 < dpush(nm, ep)                   /* push on a definition */
514 < char  *nm;
515 < register EPNODE  *ep;
513 > dpush(                  /* push on a definition */
514 >        char  *nm,
515 >        register EPNODE  *ep
516 > )
517   {
518      register VARDEF  *vp;
519  
# Line 559 | Line 524 | register EPNODE         *ep;
524  
525  
526   void
527 < addchan(sp)                     /* add an output channel assignment */
528 < EPNODE  *sp;
527 > addchan(                        /* add an output channel assignment */
528 >        EPNODE  *sp
529 > )
530   {
531      int  ch = sp->v.kid->v.chan;
532      register EPNODE  *ep, *epl;
# Line 589 | Line 555 | EPNODE *sp;
555  
556  
557   void
558 < getstatement()                  /* get next statement */
558 > getstatement(void)                      /* get next statement */
559   {
560      register EPNODE  *ep;
561      char  *qname;
# Line 632 | Line 598 | getstatement()                 /* get next statement */
598  
599  
600   EPNODE *
601 < getdefn()                       /* A -> SYM = E1 */
602 <                                /*      SYM : E1 */
603 <                                /*      FUNC(SYM,..) = E1 */
604 <                                /*      FUNC(SYM,..) : E1 */
601 > getdefn(void)
602 >        /* A -> SYM = E1 */
603 >        /*      SYM : E1 */
604 >        /*      FUNC(SYM,..) = E1 */
605 >        /*      FUNC(SYM,..) : E1 */
606   {
607      register EPNODE  *ep1, *ep2;
608  
# Line 691 | Line 658 | getdefn()                      /* A -> SYM = E1 */
658  
659  
660   EPNODE *
661 < getchan()                       /* A -> $N = E1 */
661 > getchan(void)                   /* A -> $N = E1 */
662   {
663      register EPNODE  *ep1, *ep2;
664  
# Line 723 | Line 690 | getchan()                      /* A -> $N = E1 */
690  
691  
692   static double
693 < dvalue(name, d)                 /* evaluate a variable */
694 < char  *name;
695 < EPNODE  *d;
693 > dvalue(                 /* evaluate a variable */
694 > char  *name,
695 > EPNODE  *d
696 > )
697   {
698      register EPNODE  *ep1, *ep2;
699      

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines