--- ray/src/rt/rcontrib.c 2014/07/19 20:03:03 2.22 +++ ray/src/rt/rcontrib.c 2016/04/27 21:11:32 2.28 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcontrib.c,v 2.22 2014/07/19 20:03:03 greg Exp $"; +static const char RCSid[] = "$Id: rcontrib.c,v 2.28 2016/04/27 21:11:32 greg Exp $"; #endif /* * Accumulate ray contributions for a set of materials @@ -8,7 +8,6 @@ static const char RCSid[] = "$Id: rcontrib.c,v 2.22 20 #include "copyright.h" -#include #include "rcontrib.h" #include "otypes.h" #include "source.h" @@ -102,8 +101,14 @@ addmodifier(char *modn, char *outf, char *prms, char * sprintf(errmsg, "duplicate modifier '%s'", modn); error(USER, errmsg); } - if (nmods >= MAXMODLIST) - error(INTERNAL, "too many modifiers"); + if (nmods >= MAXMODLIST) { + sprintf(errmsg, "too many modifiers (%d limit)", MAXMODLIST); + error(INTERNAL, errmsg); + } + if (!strcmp(modn, VOIDID)) { + sprintf(errmsg, "cannot track '%s' modifier", VOIDID); + error(USER, errmsg); + } modname[nmods++] = modn; /* XXX assumes static string */ lep->key = modn; /* XXX assumes static string */ if (binv == NULL) @@ -128,7 +133,7 @@ addmodifier(char *modn, char *outf, char *prms, char * error(SYSTEM, "out of memory in addmodifier"); mp->outspec = outf; /* XXX assumes static string */ mp->modname = modn; /* XXX assumes static string */ - mp->params = prms; + mp->params = prms; /* XXX assumes static string */ mp->binv = ebinv; mp->nbins = bincnt; memset(mp->cbin, 0, sizeof(DCOLOR)*bincnt); @@ -147,10 +152,16 @@ addmodfile(char *fname, char *outf, char *prms, char * char *mname[MAXMODLIST]; int i; /* find the file & store strings */ - if (wordfile(mname, getpath(fname, getrlibpath(), R_OK)) < 0) { + i = wordfile(mname, MAXMODLIST, getpath(fname, getrlibpath(), R_OK)); + if (i < 0) { sprintf(errmsg, "cannot find modifier file '%s'", fname); error(SYSTEM, errmsg); } + if (i >= MAXMODLIST-1) { + sprintf(errmsg, "too many modifiers (%d limit) in file '%s'", + MAXMODLIST-1, fname); + error(INTERNAL, errmsg); + } for (i = 0; mname[i]; i++) /* add each one */ addmodifier(mname[i], outf, prms, binv, bincnt); } @@ -169,7 +180,7 @@ quit( /* quit program */ /* Initialize our process(es) */ static void -rcinit() +rcinit(void) { int i; @@ -215,52 +226,6 @@ rcinit() /************************** MAIN CALCULATION PROCESS ***********************/ -/* Set parameters for current bin evaluation */ -void -set_eparams(char *prms) -{ - static char *last_params = NULL; - char vname[RMAXWORD]; - double value; - char *cpd; - /* check if already set */ - if ((prms == NULL) | (prms == last_params)) - return; - if (last_params != NULL && !strcmp(prms, last_params)) - return; - last_params = prms; /* assign each variable */ - while (*prms) { - if (isspace(*prms)) { - ++prms; continue; - } - if (!isalpha(*prms)) - goto bad_params; - cpd = vname; - while (*prms && (*prms != '=') & !isspace(*prms)) { - if (!isid(*prms)) - goto bad_params; - *cpd++ = *prms++; - } - if (cpd == vname) - goto bad_params; - *cpd = '\0'; - while (isspace(*prms)) prms++; - if (*prms++ != '=') - goto bad_params; - value = atof(prms); - if ((prms = fskip(prms)) == NULL) - goto bad_params; - while (isspace(*prms)) prms++; - prms += (*prms == ',') | (*prms == ';'); - varset(vname, '=', value); - } - return; -bad_params: - sprintf(errmsg, "bad parameter list '%s'", last_params); - error(USER, errmsg); -} - - /* Our trace call to sum contributions */ static void trace_contrib(RAY *r) @@ -286,7 +251,8 @@ trace_contrib(RAY *r) if ((bval = evalue(mp->binv)) <= -.5) /* and get bin number */ return; /* silently ignore negatives */ if ((bn = (int)(bval + .5)) >= mp->nbins) { - error(WARNING, "bad bin number (ignored)"); + sprintf(errmsg, "bad bin number (%d ignored)", bn); + error(WARNING, errmsg); return; } raycontrib(contr, r, PRIMARY); /* compute coefficient */ @@ -335,7 +301,7 @@ eval_rad(FVECT org, FVECT dir, double dmax) /* Accumulate and/or output ray contributions (child or only process) */ static void -done_contrib() +done_contrib(void) { MODCONT *mp; int i; @@ -356,7 +322,7 @@ done_contrib() /* Principal calculation loop (called by main) */ void -rcontrib() +rcontrib(void) { static int ignore_warning_given = 0; FVECT orig, direc;