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

Comparing ray/src/rt/rcontrib.c (file contents):
Revision 2.23 by greg, Mon Aug 25 13:18:30 2014 UTC vs.
Revision 2.28 by greg, Wed Apr 27 21:11:32 2016 UTC

# Line 8 | Line 8 | static const char RCSid[] = "$Id$";
8  
9   #include "copyright.h"
10  
11 #include <ctype.h>
11   #include "rcontrib.h"
12   #include "otypes.h"
13   #include "source.h"
# Line 102 | Line 101 | addmodifier(char *modn, char *outf, char *prms, char *
101                  sprintf(errmsg, "duplicate modifier '%s'", modn);
102                  error(USER, errmsg);
103          }
104 <        if (nmods >= MAXMODLIST)
105 <                error(INTERNAL, "too many modifiers");
104 >        if (nmods >= MAXMODLIST) {
105 >                sprintf(errmsg, "too many modifiers (%d limit)", MAXMODLIST);
106 >                error(INTERNAL, errmsg);
107 >        }
108 >        if (!strcmp(modn, VOIDID)) {
109 >                sprintf(errmsg, "cannot track '%s' modifier", VOIDID);
110 >                error(USER, errmsg);
111 >        }
112          modname[nmods++] = modn;        /* XXX assumes static string */
113          lep->key = modn;                /* XXX assumes static string */
114          if (binv == NULL)
# Line 128 | Line 133 | addmodifier(char *modn, char *outf, char *prms, char *
133                  error(SYSTEM, "out of memory in addmodifier");
134          mp->outspec = outf;             /* XXX assumes static string */
135          mp->modname = modn;             /* XXX assumes static string */
136 <        mp->params = prms;
136 >        mp->params = prms;              /* XXX assumes static string */
137          mp->binv = ebinv;
138          mp->nbins = bincnt;
139          memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt);
# Line 147 | Line 152 | addmodfile(char *fname, char *outf, char *prms, char *
152          char    *mname[MAXMODLIST];
153          int     i;
154                                          /* find the file & store strings */
155 <        if (wordfile(mname, getpath(fname, getrlibpath(), R_OK)) < 0) {
155 >        i = wordfile(mname, MAXMODLIST, getpath(fname, getrlibpath(), R_OK));
156 >        if (i < 0) {
157                  sprintf(errmsg, "cannot find modifier file '%s'", fname);
158                  error(SYSTEM, errmsg);
159          }
160 +        if (i >= MAXMODLIST-1) {
161 +                sprintf(errmsg, "too many modifiers (%d limit) in file '%s'",
162 +                                MAXMODLIST-1, fname);
163 +                error(INTERNAL, errmsg);
164 +        }
165          for (i = 0; mname[i]; i++)      /* add each one */
166                  addmodifier(mname[i], outf, prms, binv, bincnt);
167   }
# Line 169 | Line 180 | quit(                  /* quit program */
180  
181   /* Initialize our process(es) */
182   static void
183 < rcinit()
183 > rcinit(void)
184   {
185          int     i;
186  
# Line 215 | Line 226 | rcinit()
226  
227   /************************** MAIN CALCULATION PROCESS ***********************/
228  
218 /* Set parameters for current bin evaluation */
219 void
220 set_eparams(char *prms)
221 {
222        static char     *last_params = NULL;
223        char            vname[RMAXWORD];
224        double          value;
225        char            *cpd;
226                                        /* check if already set */
227        if ((prms == NULL) | (prms == last_params))
228                return;
229        if (last_params != NULL && !strcmp(prms, last_params))
230                return;
231        last_params = prms;             /* assign each variable */
232        while (*prms) {
233                if (isspace(*prms)) {
234                        ++prms; continue;
235                }
236                if (!isalpha(*prms))
237                        goto bad_params;
238                cpd = vname;
239                while (*prms && (*prms != '=') & !isspace(*prms)) {
240                        if (!isid(*prms))
241                                goto bad_params;
242                        *cpd++ = *prms++;
243                }
244                if (cpd == vname)
245                        goto bad_params;
246                *cpd = '\0';
247                while (isspace(*prms)) prms++;
248                if (*prms++ != '=')
249                        goto bad_params;
250                value = atof(prms);
251                if ((prms = fskip(prms)) == NULL)
252                        goto bad_params;
253                while (isspace(*prms)) prms++;
254                prms += (*prms == ',') | (*prms == ';');
255                varset(vname, '=', value);
256        }
257        return;
258 bad_params:
259        sprintf(errmsg, "bad parameter list '%s'", last_params);
260        error(USER, errmsg);
261 }
262
263
229   /* Our trace call to sum contributions */
230   static void
231   trace_contrib(RAY *r)
# Line 336 | Line 301 | eval_rad(FVECT org, FVECT dir, double dmax)
301  
302   /* Accumulate and/or output ray contributions (child or only process) */
303   static void
304 < done_contrib()
304 > done_contrib(void)
305   {
306          MODCONT *mp;
307          int     i;
# Line 357 | Line 322 | done_contrib()
322  
323   /* Principal calculation loop (called by main) */
324   void
325 < rcontrib()
325 > rcontrib(void)
326   {
327          static int      ignore_warning_given = 0;
328          FVECT           orig, direc;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines