11 |
|
#include "paths.h" |
12 |
|
#include "otypes.h" |
13 |
|
#include "func.h" |
14 |
+ |
#include <ctype.h> |
15 |
|
|
16 |
|
|
17 |
|
#define INITFILE "rayinit.cal" |
37 |
|
|
38 |
|
|
39 |
|
void |
40 |
< |
initfunc() /* initialize function evaluation */ |
40 |
> |
initfunc(void) /* initialize function evaluation */ |
41 |
|
{ |
42 |
|
if (!rayinitcal[0]) /* already done? */ |
43 |
|
return; |
63 |
|
} |
64 |
|
|
65 |
|
|
66 |
+ |
/* Set parameters for current evaluation */ |
67 |
+ |
void |
68 |
+ |
set_eparams(char *prms) |
69 |
+ |
{ |
70 |
+ |
static char *last_params; |
71 |
+ |
static int lplen = 0; |
72 |
+ |
int len; |
73 |
+ |
char vname[RMAXWORD]; |
74 |
+ |
double value; |
75 |
+ |
char *cpd; |
76 |
+ |
/* check if already set */ |
77 |
+ |
if (prms == NULL || !*prms) |
78 |
+ |
return; |
79 |
+ |
if (lplen && !strcmp(prms, last_params)) |
80 |
+ |
return; |
81 |
+ |
len = strlen(prms); /* record new settings */ |
82 |
+ |
if ((lplen != 0) & (lplen <= len)) { |
83 |
+ |
free(last_params); |
84 |
+ |
lplen = 0; |
85 |
+ |
} |
86 |
+ |
if (!lplen) { |
87 |
+ |
lplen = len + 100; |
88 |
+ |
last_params = (char *)malloc(lplen); |
89 |
+ |
if (last_params == NULL) |
90 |
+ |
error(SYSTEM, "out of memory in set_eparams()"); |
91 |
+ |
} |
92 |
+ |
strcpy(last_params, prms); |
93 |
+ |
/* assign each variable */ |
94 |
+ |
while (*prms) { |
95 |
+ |
if (isspace(*prms)) { |
96 |
+ |
++prms; continue; |
97 |
+ |
} |
98 |
+ |
if (!isalpha(*prms)) |
99 |
+ |
goto bad_params; |
100 |
+ |
cpd = vname; |
101 |
+ |
while (*prms && (*prms != '=') & !isspace(*prms)) { |
102 |
+ |
if (!isid(*prms) | (cpd-vname >= RMAXWORD-1)) |
103 |
+ |
goto bad_params; |
104 |
+ |
*cpd++ = *prms++; |
105 |
+ |
} |
106 |
+ |
*cpd = '\0'; |
107 |
+ |
while (isspace(*prms)) prms++; |
108 |
+ |
if (*prms++ != '=') |
109 |
+ |
goto bad_params; |
110 |
+ |
value = atof(prms); |
111 |
+ |
if ((prms = fskip(prms)) == NULL) |
112 |
+ |
goto bad_params; |
113 |
+ |
while (isspace(*prms)) prms++; |
114 |
+ |
prms += (*prms == ',') | (*prms == ';'); |
115 |
+ |
varset(vname, '=', value); |
116 |
+ |
} |
117 |
+ |
return; |
118 |
+ |
bad_params: |
119 |
+ |
sprintf(errmsg, "bad parameter list '%s'", last_params); |
120 |
+ |
error(USER, errmsg); |
121 |
+ |
} |
122 |
+ |
|
123 |
+ |
|
124 |
|
MFUNC * |
125 |
|
getfunc( /* get function for this modifier */ |
126 |
|
OBJREC *m, |
298 |
|
|
299 |
|
if ((ffname = getpath(fname, getrlibpath(), R_OK)) == NULL) { |
300 |
|
sprintf(errmsg, "cannot find function file \"%s\"", fname); |
301 |
< |
error(USER, errmsg); |
301 |
> |
error(SYSTEM, errmsg); |
302 |
|
} |
303 |
|
fcompile(ffname); |
304 |
|
} |
310 |
|
int n; |
311 |
|
|
312 |
|
if (fobj == NULL) |
313 |
< |
error(USER, "arg(n) called without a context"); |
313 |
> |
error(INTERNAL, "arg(n) called without a modifier context"); |
314 |
|
|
315 |
|
n = argument(1) + .5; /* round to integer */ |
316 |
|
|