208 |
|
} |
209 |
|
|
210 |
|
|
211 |
+ |
#define NOCHAR 127 /* constant for character to delete */ |
212 |
+ |
|
213 |
+ |
|
214 |
|
load(rfname) /* load Radiance simulation file */ |
215 |
|
char *rfname; |
216 |
|
{ |
226 |
|
for (cp = buf; *cp; cp++) { |
227 |
|
switch (*cp) { |
228 |
|
case '\\': |
229 |
< |
case '\n': |
227 |
< |
*cp = ' '; |
229 |
> |
*cp++ = NOCHAR; |
230 |
|
continue; |
231 |
|
case '#': |
232 |
|
*cp = '\0'; |
246 |
|
register char *ass; |
247 |
|
{ |
248 |
|
char varname[32]; |
249 |
+ |
char varval[512]; |
250 |
+ |
int n; |
251 |
|
register char *cp; |
252 |
|
register VARIABLE *vp; |
253 |
|
register int i; |
250 |
– |
int n; |
254 |
|
|
255 |
|
while (isspace(*ass)) /* skip leading space */ |
256 |
|
ass++; |
264 |
|
/* trim value */ |
265 |
|
while (isspace(*ass) || *ass == '=') |
266 |
|
ass++; |
267 |
< |
cp = ass + strlen(ass); |
268 |
< |
do |
269 |
< |
*cp-- = '\0'; |
267 |
< |
while (cp >= ass && isspace(*cp)); |
268 |
< |
n = cp - ass + 1; |
267 |
> |
for (n = strlen(ass); n > 0; n--) |
268 |
> |
if (!isspace(ass[n-1])) |
269 |
> |
break; |
270 |
|
if (!n) { |
271 |
|
fprintf(stderr, "%s: warning - missing value for variable '%s'\n", |
272 |
|
progname, varname); |
291 |
|
vp->value = malloc(n+1); |
292 |
|
if (vp->value == NULL) |
293 |
|
syserr(progname); |
294 |
< |
strcpy(vp->value+i, ass); |
294 |
> |
cp = vp->value+i; /* copy value, squeezing spaces */ |
295 |
> |
*cp = *ass; |
296 |
> |
for (i = 1; i <= n; i++) { |
297 |
> |
if (ass[i] == NOCHAR) |
298 |
> |
continue; |
299 |
> |
if (isspace(*cp)) |
300 |
> |
while (isspace(ass[i])) |
301 |
> |
i++; |
302 |
> |
*++cp = ass[i]; |
303 |
> |
} |
304 |
> |
*++cp = '\0'; |
305 |
|
vp->nass++; |
306 |
|
} |
307 |
|
|