| 8 |
|
|
| 9 |
|
#include "copyright.h" |
| 10 |
|
|
| 11 |
– |
#include <ctype.h> |
| 11 |
|
#include "rcontrib.h" |
| 12 |
|
#include "otypes.h" |
| 13 |
|
#include "source.h" |
| 103 |
|
} |
| 104 |
|
if (nmods >= MAXMODLIST) |
| 105 |
|
error(INTERNAL, "too many modifiers"); |
| 106 |
+ |
if (!strcmp(modn, VOIDID)) { |
| 107 |
+ |
sprintf(errmsg, "cannot track '%s' modifier", VOIDID); |
| 108 |
+ |
error(USER, errmsg); |
| 109 |
+ |
} |
| 110 |
|
modname[nmods++] = modn; /* XXX assumes static string */ |
| 111 |
|
lep->key = modn; /* XXX assumes static string */ |
| 112 |
|
if (binv == NULL) |
| 218 |
|
|
| 219 |
|
/************************** MAIN CALCULATION PROCESS ***********************/ |
| 220 |
|
|
| 218 |
– |
/* Set parameters for current bin evaluation */ |
| 219 |
– |
static void |
| 220 |
– |
set_eparams(char *prms) |
| 221 |
– |
{ |
| 222 |
– |
char vname[64]; |
| 223 |
– |
double value; |
| 224 |
– |
char *cps, *cpd; |
| 225 |
– |
/* assign each variable */ |
| 226 |
– |
for (cps = prms; *cps; cps++) { |
| 227 |
– |
if (isspace(*cps)) |
| 228 |
– |
continue; |
| 229 |
– |
if (!isalpha(*cps)) |
| 230 |
– |
goto bad_params; |
| 231 |
– |
cpd = vname; |
| 232 |
– |
while (*cps && (*cps != '=') & !isspace(*cps)) { |
| 233 |
– |
if (!isid(*cps)) |
| 234 |
– |
goto bad_params; |
| 235 |
– |
*cpd++ = *cps++; |
| 236 |
– |
} |
| 237 |
– |
if (cpd == vname) |
| 238 |
– |
goto bad_params; |
| 239 |
– |
*cpd = '\0'; |
| 240 |
– |
while (isspace(*cps)) cps++; |
| 241 |
– |
if (*cps++ != '=') |
| 242 |
– |
goto bad_params; |
| 243 |
– |
value = atof(cps); |
| 244 |
– |
if ((cps = fskip(cps)) == NULL) |
| 245 |
– |
goto bad_params; |
| 246 |
– |
while (isspace(*cps)) cps++; |
| 247 |
– |
cps += (*cps == ',') | (*cps == ';'); |
| 248 |
– |
varset(vname, '=', value); |
| 249 |
– |
} |
| 250 |
– |
return; |
| 251 |
– |
bad_params: |
| 252 |
– |
sprintf(errmsg, "bad parameter list '%s'", prms); |
| 253 |
– |
error(USER, errmsg); |
| 254 |
– |
} |
| 255 |
– |
|
| 221 |
|
/* Our trace call to sum contributions */ |
| 222 |
|
static void |
| 223 |
|
trace_contrib(RAY *r) |
| 224 |
|
{ |
| 260 |
– |
static char *last_params = NULL; |
| 225 |
|
MODCONT *mp; |
| 226 |
|
double bval; |
| 227 |
|
int bn; |
| 239 |
|
return; |
| 240 |
|
|
| 241 |
|
worldfunc(RCCONTEXT, r); /* else set context */ |
| 242 |
< |
if ((mp->params != NULL) & (mp->params != last_params) && |
| 279 |
< |
(last_params == NULL || strcmp(mp->params, last_params))) |
| 280 |
< |
set_eparams(last_params = (char *)mp->params); |
| 242 |
> |
set_eparams((char *)mp->params); |
| 243 |
|
if ((bval = evalue(mp->binv)) <= -.5) /* and get bin number */ |
| 244 |
|
return; /* silently ignore negatives */ |
| 245 |
|
if ((bn = (int)(bval + .5)) >= mp->nbins) { |
| 246 |
< |
error(WARNING, "bad bin number (ignored)"); |
| 246 |
> |
sprintf(errmsg, "bad bin number (%d ignored)", bn); |
| 247 |
> |
error(WARNING, errmsg); |
| 248 |
|
return; |
| 249 |
|
} |
| 250 |
|
raycontrib(contr, r, PRIMARY); /* compute coefficient */ |