13 |
|
#include <string.h> |
14 |
|
|
15 |
|
#include "platform.h" |
16 |
+ |
#include "rtprocess.h" /* win_popen() */ |
17 |
+ |
#include "paths.h" |
18 |
|
#include "ray.h" |
19 |
+ |
#include "source.h" |
20 |
+ |
#include "ambient.h" |
21 |
|
#include "otypes.h" |
22 |
|
#include "rpaint.h" |
23 |
|
|
39 |
|
|
40 |
|
|
41 |
|
void |
42 |
< |
getframe(s) /* get a new frame */ |
43 |
< |
char *s; |
42 |
> |
getframe( /* get a new frame */ |
43 |
> |
char *s |
44 |
> |
) |
45 |
|
{ |
46 |
|
if (getrect(s, &pframe) < 0) |
47 |
|
return; |
50 |
|
|
51 |
|
|
52 |
|
void |
53 |
< |
getrepaint(s) /* get area and repaint */ |
54 |
< |
char *s; |
53 |
> |
getrepaint( /* get area and repaint */ |
54 |
> |
char *s |
55 |
> |
) |
56 |
|
{ |
57 |
|
RECT box; |
58 |
|
|
59 |
|
if (getrect(s, &box) < 0) |
60 |
|
return; |
61 |
< |
paintrect(&ptrunk, 0, 0, hresolu, vresolu, &box); |
61 |
> |
paintrect(&ptrunk, &box); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
void |
66 |
< |
getview(s) /* get/show view parameters */ |
67 |
< |
char *s; |
66 |
> |
getview( /* get/show/save view parameters */ |
67 |
> |
char *s |
68 |
> |
) |
69 |
|
{ |
70 |
|
FILE *fp; |
71 |
|
char buf[128]; |
72 |
|
char *fname; |
73 |
|
int change = 0; |
74 |
< |
VIEW nv; |
74 |
> |
VIEW nv = ourview; |
75 |
|
|
76 |
|
while (isspace(*s)) |
77 |
|
s++; |
78 |
|
if (*s == '-') { /* command line parameters */ |
72 |
– |
nv = ourview; |
79 |
|
if (sscanview(&nv, s)) |
80 |
|
newview(&nv); |
81 |
|
else |
82 |
|
error(COMMAND, "bad view option(s)"); |
83 |
|
return; |
84 |
|
} |
85 |
< |
if (sscanf(s, "%s", buf) == 1) { /* write parameters to a file */ |
85 |
> |
if (nextword(buf, sizeof(buf), s) != NULL) { /* write to a file */ |
86 |
|
if ((fname = getpath(buf, NULL, 0)) == NULL || |
87 |
|
(fp = fopen(fname, "a")) == NULL) { |
88 |
|
sprintf(errmsg, "cannot open \"%s\"", buf); |
103 |
|
if (buf[0] && buf[0] != ourview.type) { |
104 |
|
nv.type = buf[0]; |
105 |
|
change++; |
106 |
< |
} else |
101 |
< |
nv.type = ourview.type; |
106 |
> |
} |
107 |
|
sprintf(buf, "view point (%.6g %.6g %.6g): ", |
108 |
|
ourview.vp[0], ourview.vp[1], ourview.vp[2]); |
109 |
|
(*dev->comout)(buf); |
111 |
|
if (buf[0] == CTRL('C')) return; |
112 |
|
if (sscanvec(buf, nv.vp)) |
113 |
|
change++; |
109 |
– |
else |
110 |
– |
VCOPY(nv.vp, ourview.vp); |
114 |
|
sprintf(buf, "view direction (%.6g %.6g %.6g): ", |
115 |
< |
ourview.vdir[0], ourview.vdir[1], ourview.vdir[2]); |
115 |
> |
ourview.vdir[0]*ourview.vdist, |
116 |
> |
ourview.vdir[1]*ourview.vdist, |
117 |
> |
ourview.vdir[2]*ourview.vdist); |
118 |
|
(*dev->comout)(buf); |
119 |
|
(*dev->comin)(buf, NULL); |
120 |
|
if (buf[0] == CTRL('C')) return; |
121 |
< |
if (sscanvec(buf, nv.vdir)) |
121 |
> |
if (sscanvec(buf, nv.vdir)) { |
122 |
> |
nv.vdist = 1.; |
123 |
|
change++; |
124 |
< |
else |
119 |
< |
VCOPY(nv.vdir, ourview.vdir); |
124 |
> |
} |
125 |
|
sprintf(buf, "view up (%.6g %.6g %.6g): ", |
126 |
|
ourview.vup[0], ourview.vup[1], ourview.vup[2]); |
127 |
|
(*dev->comout)(buf); |
129 |
|
if (buf[0] == CTRL('C')) return; |
130 |
|
if (sscanvec(buf, nv.vup)) |
131 |
|
change++; |
127 |
– |
else |
128 |
– |
VCOPY(nv.vup, ourview.vup); |
132 |
|
sprintf(buf, "view horiz and vert size (%.6g %.6g): ", |
133 |
|
ourview.horiz, ourview.vert); |
134 |
|
(*dev->comout)(buf); |
136 |
|
if (buf[0] == CTRL('C')) return; |
137 |
|
if (sscanf(buf, "%lf %lf", &nv.horiz, &nv.vert) == 2) |
138 |
|
change++; |
136 |
– |
else { |
137 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
138 |
– |
} |
139 |
|
sprintf(buf, "fore and aft clipping plane (%.6g %.6g): ", |
140 |
|
ourview.vfore, ourview.vaft); |
141 |
|
(*dev->comout)(buf); |
143 |
|
if (buf[0] == CTRL('C')) return; |
144 |
|
if (sscanf(buf, "%lf %lf", &nv.vfore, &nv.vaft) == 2) |
145 |
|
change++; |
146 |
– |
else { |
147 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
148 |
– |
} |
146 |
|
sprintf(buf, "view shift and lift (%.6g %.6g): ", |
147 |
|
ourview.hoff, ourview.voff); |
148 |
|
(*dev->comout)(buf); |
150 |
|
if (buf[0] == CTRL('C')) return; |
151 |
|
if (sscanf(buf, "%lf %lf", &nv.hoff, &nv.voff) == 2) |
152 |
|
change++; |
156 |
– |
else { |
157 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
158 |
– |
} |
153 |
|
if (change) |
154 |
|
newview(&nv); |
155 |
|
} |
156 |
|
|
157 |
|
|
158 |
|
void |
159 |
< |
lastview(s) /* return to a previous view */ |
160 |
< |
char *s; |
159 |
> |
lastview( /* return to a previous view */ |
160 |
> |
char *s |
161 |
> |
) |
162 |
|
{ |
163 |
|
char buf[128]; |
164 |
|
char *fname; |
165 |
|
int success; |
166 |
|
VIEW nv; |
167 |
< |
|
168 |
< |
if (sscanf(s, "%s", buf) == 1) { /* get parameters from a file */ |
167 |
> |
/* get parameters from a file */ |
168 |
> |
if (nextword(buf, sizeof(buf), s) != NULL) { |
169 |
|
nv = stdview; |
170 |
|
if ((fname = getpath(buf, "", R_OK)) == NULL || |
171 |
|
(success = viewfile(fname, &nv, NULL)) == -1) { |
186 |
|
nv = ourview; |
187 |
|
ourview = oldview; |
188 |
|
oldview = nv; |
189 |
< |
newimage(); |
189 |
> |
newimage(NULL); |
190 |
|
} |
191 |
|
|
192 |
|
|
193 |
|
void |
194 |
< |
saveview(s) /* save view to rad file */ |
195 |
< |
char *s; |
194 |
> |
saveview( /* save view to rad file */ |
195 |
> |
char *s |
196 |
> |
) |
197 |
|
{ |
198 |
|
char view[64]; |
199 |
|
char *fname; |
206 |
|
} |
207 |
|
s = sskip(s); |
208 |
|
} |
209 |
< |
while (isspace(*s)) |
214 |
< |
s++; |
215 |
< |
if (*s) |
216 |
< |
atos(rifname, sizeof(rifname), s); |
217 |
< |
else if (rifname[0] == '\0') { |
209 |
> |
if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { |
210 |
|
error(COMMAND, "no previous rad file"); |
211 |
|
return; |
212 |
|
} |
225 |
|
|
226 |
|
|
227 |
|
void |
228 |
< |
loadview(s) /* load view from rad file */ |
229 |
< |
char *s; |
228 |
> |
loadview( /* load view from rad file */ |
229 |
> |
char *s |
230 |
> |
) |
231 |
|
{ |
232 |
|
char buf[512]; |
233 |
|
char *fname; |
239 |
|
s = sskip(s); |
240 |
|
else |
241 |
|
strcat(buf, "1"); |
242 |
< |
if (*s) |
250 |
< |
atos(rifname, sizeof(rifname), s); |
251 |
< |
else if (rifname[0] == '\0') { |
242 |
> |
if (nextword(rifname, sizeof(rifname), s) == NULL && !rifname[0]) { |
243 |
|
error(COMMAND, "no previous rad file"); |
244 |
|
return; |
245 |
|
} |
266 |
|
|
267 |
|
|
268 |
|
void |
269 |
< |
getaim(s) /* aim camera */ |
270 |
< |
char *s; |
269 |
> |
getaim( /* aim camera */ |
270 |
> |
char *s |
271 |
> |
) |
272 |
|
{ |
273 |
+ |
VIEW nv = ourview; |
274 |
|
double zfact; |
282 |
– |
VIEW nv; |
275 |
|
|
276 |
|
if (getinterest(s, 1, nv.vdir, &zfact) < 0) |
277 |
|
return; |
286 |
– |
nv.type = ourview.type; |
287 |
– |
VCOPY(nv.vp, ourview.vp); |
288 |
– |
VCOPY(nv.vup, ourview.vup); |
289 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
290 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
291 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
278 |
|
zoomview(&nv, zfact); |
279 |
|
newview(&nv); |
280 |
|
} |
281 |
|
|
282 |
|
|
283 |
|
void |
284 |
< |
getmove(s) /* move camera */ |
285 |
< |
char *s; |
284 |
> |
getfocus( /* set focus distance */ |
285 |
> |
char *s |
286 |
> |
) |
287 |
|
{ |
288 |
+ |
char buf[64]; |
289 |
+ |
double dist; |
290 |
+ |
|
291 |
+ |
if (sscanf(s, "%lf", &dist) < 1) { |
292 |
+ |
int x, y; |
293 |
+ |
RAY thisray; |
294 |
+ |
if (dev->getcur == NULL) |
295 |
+ |
return; |
296 |
+ |
(*dev->comout)("Pick focus point\n"); |
297 |
+ |
if ((*dev->getcur)(&x, &y) == ABORT) |
298 |
+ |
return; |
299 |
+ |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
300 |
+ |
&ourview, (x+.5)/hresolu, (y+.5)/vresolu)) < -FTINY) { |
301 |
+ |
error(COMMAND, "not on image"); |
302 |
+ |
return; |
303 |
+ |
} |
304 |
+ |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
305 |
+ |
if (!localhit(&thisray, &thescene)) { |
306 |
+ |
error(COMMAND, "not a local object"); |
307 |
+ |
return; |
308 |
+ |
} |
309 |
+ |
dist = thisray.rot; |
310 |
+ |
} else if (dist <= .0) { |
311 |
+ |
error(COMMAND, "focus distance must be positive"); |
312 |
+ |
return; |
313 |
+ |
} |
314 |
+ |
ourview.vdist = dist; |
315 |
+ |
sprintf(buf, "Focus distance set to %f\n", dist); |
316 |
+ |
(*dev->comout)(buf); |
317 |
+ |
} |
318 |
+ |
|
319 |
+ |
|
320 |
+ |
void |
321 |
+ |
getmove( /* move camera */ |
322 |
+ |
char *s |
323 |
+ |
) |
324 |
+ |
{ |
325 |
|
FVECT vc; |
326 |
|
double mag; |
327 |
|
|
332 |
|
|
333 |
|
|
334 |
|
void |
335 |
< |
getrotate(s) /* rotate camera */ |
336 |
< |
char *s; |
335 |
> |
getrotate( /* rotate camera */ |
336 |
> |
char *s |
337 |
> |
) |
338 |
|
{ |
339 |
< |
VIEW nv; |
339 |
> |
VIEW nv = ourview; |
340 |
|
FVECT v1; |
341 |
|
double angle, elev, zfact; |
342 |
|
|
345 |
|
error(COMMAND, "missing angle"); |
346 |
|
return; |
347 |
|
} |
323 |
– |
nv.type = ourview.type; |
324 |
– |
VCOPY(nv.vp, ourview.vp); |
325 |
– |
VCOPY(nv.vup, ourview.vup); |
326 |
– |
nv.hoff = ourview.hoff; nv.voff = ourview.voff; |
327 |
– |
nv.vfore = ourview.vfore; nv.vaft = ourview.vaft; |
348 |
|
spinvector(nv.vdir, ourview.vdir, ourview.vup, angle*(PI/180.)); |
349 |
|
if (elev != 0.0) { |
350 |
|
fcross(v1, nv.vdir, ourview.vup); |
351 |
|
normalize(v1); |
352 |
|
spinvector(nv.vdir, nv.vdir, v1, elev*(PI/180.)); |
353 |
|
} |
334 |
– |
nv.horiz = ourview.horiz; nv.vert = ourview.vert; |
354 |
|
zoomview(&nv, zfact); |
355 |
|
newview(&nv); |
356 |
|
} |
357 |
|
|
358 |
|
|
359 |
|
void |
360 |
< |
getpivot(s) /* pivot viewpoint */ |
361 |
< |
register char *s; |
360 |
> |
getpivot( /* pivot viewpoint */ |
361 |
> |
char *s |
362 |
> |
) |
363 |
|
{ |
364 |
|
FVECT vc; |
365 |
|
double angle, elev, mag; |
376 |
|
|
377 |
|
|
378 |
|
void |
379 |
< |
getexposure(s) /* get new exposure */ |
380 |
< |
char *s; |
379 |
> |
getexposure( /* get new exposure */ |
380 |
> |
char *s |
381 |
> |
) |
382 |
|
{ |
383 |
|
char buf[128]; |
384 |
< |
register char *cp; |
364 |
< |
RECT r; |
384 |
> |
char *cp; |
385 |
|
int x, y; |
386 |
< |
register PNODE *p = &ptrunk; |
386 |
> |
PNODE *p = &ptrunk; |
387 |
|
int adapt = 0; |
388 |
|
double e = 1.0; |
389 |
|
|
400 |
|
(*dev->comout)("Pick point for exposure\n"); |
401 |
|
if ((*dev->getcur)(&x, &y) == ABORT) |
402 |
|
return; |
403 |
< |
r.l = r.d = 0; |
384 |
< |
r.r = hresolu; r.u = vresolu; |
385 |
< |
p = findrect(x, y, &ptrunk, &r, -1); |
403 |
> |
p = findrect(x, y, &ptrunk, -1); |
404 |
|
} else { |
405 |
|
if (*cp == '=') { /* absolute setting */ |
406 |
|
p = NULL; |
423 |
|
e *= atof(cp); |
424 |
|
} |
425 |
|
if (p != NULL) { /* relative setting */ |
426 |
+ |
compavg(p); |
427 |
|
if (bright(p->v) < 1e-15) { |
428 |
|
error(COMMAND, "cannot normalize to zero"); |
429 |
|
return; |
441 |
|
} |
442 |
|
|
443 |
|
typedef union {int i; double d; COLOR C;} *MyUptr; |
444 |
+ |
#define FEQ(x,y) (fabs((x)-(y)) <= FTINY) |
445 |
|
|
446 |
|
int |
447 |
< |
getparam(str, dsc, typ, p) /* get variable from user */ |
448 |
< |
char *str, *dsc; |
449 |
< |
int typ; |
450 |
< |
void *p; |
447 |
> |
getparam( /* get variable from user */ |
448 |
> |
char *str, |
449 |
> |
char *dsc, |
450 |
> |
int typ, |
451 |
> |
void *p |
452 |
> |
) |
453 |
|
{ |
454 |
< |
register MyUptr ptr = (MyUptr)p; |
454 |
> |
MyUptr ptr = (MyUptr)p; |
455 |
|
int i0; |
456 |
|
double d0, d1, d2; |
457 |
|
char buf[48]; |
466 |
|
if (sscanf(buf, "%d", &i0) != 1) |
467 |
|
return(0); |
468 |
|
} |
469 |
+ |
if (ptr->i == i0) |
470 |
+ |
return(0); |
471 |
|
ptr->i = i0; |
472 |
< |
return(1); |
472 |
> |
break; |
473 |
|
case 'r': /* real */ |
474 |
|
if (sscanf(str, "%lf", &d0) != 1) { |
475 |
|
(*dev->comout)(dsc); |
479 |
|
if (sscanf(buf, "%lf", &d0) != 1) |
480 |
|
return(0); |
481 |
|
} |
482 |
+ |
if (FEQ(ptr->d, d0)) |
483 |
+ |
return(0); |
484 |
|
ptr->d = d0; |
485 |
< |
return(1); |
485 |
> |
break; |
486 |
|
case 'b': /* boolean */ |
487 |
|
if (sscanf(str, "%1s", buf) != 1) { |
488 |
|
(*dev->comout)(dsc); |
489 |
|
sprintf(buf, "? (%c): ", ptr->i ? 'y' : 'n'); |
490 |
|
(*dev->comout)(buf); |
491 |
|
(*dev->comin)(buf, NULL); |
492 |
< |
if (buf[0] == '\0' || |
467 |
< |
strchr("yY+1tTnN-0fF", buf[0]) == NULL) |
492 |
> |
if (buf[0] == '\0') |
493 |
|
return(0); |
494 |
|
} |
495 |
< |
ptr->i = strchr("yY+1tT", buf[0]) != NULL; |
496 |
< |
return(1); |
495 |
> |
if (strchr("yY+1tTnN-0fF", buf[0]) == NULL) |
496 |
> |
return(0); |
497 |
> |
i0 = strchr("yY+1tT", buf[0]) != NULL; |
498 |
> |
if (ptr->i == i0) |
499 |
> |
return(0); |
500 |
> |
ptr->i = i0; |
501 |
> |
break; |
502 |
|
case 'C': /* color */ |
503 |
|
if (sscanf(str, "%lf %lf %lf", &d0, &d1, &d2) != 3) { |
504 |
|
(*dev->comout)(dsc); |
511 |
|
if (sscanf(buf, "%lf %lf %lf", &d0, &d1, &d2) != 3) |
512 |
|
return(0); |
513 |
|
} |
514 |
+ |
if (FEQ(colval(ptr->C,RED), d0) && |
515 |
+ |
FEQ(colval(ptr->C,GRN), d1) && |
516 |
+ |
FEQ(colval(ptr->C,BLU), d2)) |
517 |
+ |
return(0); |
518 |
|
setcolor(ptr->C, d0, d1, d2); |
519 |
< |
return(1); |
519 |
> |
break; |
520 |
> |
default: |
521 |
> |
return(0); /* shouldn't happen */ |
522 |
|
} |
523 |
+ |
newparam++; |
524 |
+ |
return(1); |
525 |
|
} |
526 |
|
|
527 |
|
|
528 |
|
void |
529 |
< |
setparam(s) /* get/set program parameter */ |
530 |
< |
register char *s; |
529 |
> |
setparam( /* get/set program parameter */ |
530 |
> |
char *s |
531 |
> |
) |
532 |
|
{ |
533 |
+ |
int prev_newp = newparam; |
534 |
|
char buf[128]; |
535 |
|
|
536 |
|
if (s[0] == '\0') { |
537 |
|
(*dev->comout)( |
538 |
< |
"aa ab ad ar as av aw b dc dv dj ds dt i lr lw me ma mg ms ps pt sj st bv: "); |
538 |
> |
"aa ab ad ar as av aw b bv dc dv dj ds dt i lr lw me ma mg ms ps pt ss st u: "); |
539 |
|
(*dev->comin)(buf, NULL); |
540 |
|
s = buf; |
541 |
|
} |
542 |
|
switch (s[0]) { |
543 |
+ |
case 'u': /* uncorrelated sampling */ |
544 |
+ |
getparam(s+1, "uncorrelated sampling", 'b', |
545 |
+ |
(void *)&rand_samp); |
546 |
+ |
break; |
547 |
|
case 'l': /* limit */ |
548 |
|
switch (s[1]) { |
549 |
|
case 'w': /* weight */ |
596 |
|
case 'n': case 'N': case 'f': case 'F': case '0': case '-': |
597 |
|
getparam(s+1, "black and white", 'b', |
598 |
|
(void *)&greyscale); |
599 |
+ |
newparam = prev_newp; |
600 |
|
break; |
601 |
|
default: |
602 |
|
goto badparam; |
679 |
|
default: |
680 |
|
goto badparam; |
681 |
|
} |
682 |
+ |
newparam = prev_newp; |
683 |
|
break; |
684 |
|
case 's': /* specular */ |
685 |
|
switch (s[1]) { |
686 |
< |
case 'j': /* jitter */ |
687 |
< |
getparam(s+2, "specular jitter", 'r', |
686 |
> |
case 's': /* sampling */ |
687 |
> |
getparam(s+2, "specular sampling", 'r', |
688 |
|
(void *)&specjitter); |
689 |
|
break; |
690 |
|
case 't': /* threshold */ |
708 |
|
|
709 |
|
|
710 |
|
void |
711 |
< |
traceray(s) /* trace a single ray */ |
712 |
< |
char *s; |
711 |
> |
traceray( /* trace a single ray */ |
712 |
> |
char *s |
713 |
> |
) |
714 |
|
{ |
715 |
< |
char buf[128]; |
716 |
< |
int x, y; |
670 |
< |
OBJREC *ino; |
671 |
< |
RAY thisray; |
715 |
> |
RAY thisray; |
716 |
> |
char buf[512]; |
717 |
|
|
718 |
|
thisray.rmax = 0.0; |
719 |
|
|
720 |
|
if (!sscanvec(s, thisray.rorg) || |
721 |
|
!sscanvec(sskip2(s,3), thisray.rdir)) { |
722 |
+ |
int x, y; |
723 |
|
|
724 |
|
if (dev->getcur == NULL) |
725 |
|
return; |
738 |
|
return; |
739 |
|
} |
740 |
|
|
741 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
696 |
< |
|
697 |
< |
rayvalue(&thisray); |
741 |
> |
ray_trace(&thisray); |
742 |
|
|
743 |
|
if (thisray.ro == NULL) |
744 |
|
(*dev->comout)("ray hit nothing"); |
745 |
|
else { |
746 |
< |
sprintf(buf, "ray hit %s%s %s \"%s\"", |
747 |
< |
thisray.rod < 0.0 ? "back of " : "", |
748 |
< |
thisray.ro->omod == OVOID ? VOIDID : |
749 |
< |
objptr(thisray.ro->omod)->oname, |
746 |
> |
OBJREC *mat = NULL; |
747 |
> |
OBJREC *mod = NULL; |
748 |
> |
char matspec[256]; |
749 |
> |
OBJREC *ino; |
750 |
> |
|
751 |
> |
matspec[0] = '\0'; |
752 |
> |
if (thisray.ro->omod != OVOID) { |
753 |
> |
mod = objptr(thisray.ro->omod); |
754 |
> |
mat = findmaterial(mod); |
755 |
> |
} |
756 |
> |
if (thisray.rod < 0.0) |
757 |
> |
strcpy(matspec, "back of "); |
758 |
> |
if (mod != NULL) { |
759 |
> |
strcat(matspec, mod->oname); |
760 |
> |
if (mat != mod && mat != NULL) |
761 |
> |
sprintf(matspec+strlen(matspec), |
762 |
> |
" (%s)", mat->oname); |
763 |
> |
} else |
764 |
> |
strcat(matspec, VOIDID); |
765 |
> |
sprintf(buf, "ray hit %s %s \"%s\"", matspec, |
766 |
|
ofun[thisray.ro->otype].funame, |
767 |
|
thisray.ro->oname); |
768 |
|
if ((ino = objptr(thisray.robj)) != thisray.ro) |
791 |
|
|
792 |
|
|
793 |
|
void |
794 |
< |
writepict(s) /* write the picture to a file */ |
795 |
< |
char *s; |
794 |
> |
writepict( /* write the picture to a file */ |
795 |
> |
char *s |
796 |
> |
) |
797 |
|
{ |
798 |
|
static char buf[128]; |
799 |
|
char *fname; |
800 |
|
FILE *fp; |
801 |
|
COLR *scanline; |
802 |
|
int y; |
803 |
< |
|
804 |
< |
while (isspace(*s)) |
744 |
< |
s++; |
745 |
< |
if (*s) |
746 |
< |
atos(buf, sizeof(buf), s); |
747 |
< |
else if (buf[0] == '\0') { |
803 |
> |
/* XXX relies on words.c 2.11 behavior */ |
804 |
> |
if (nextword(buf, sizeof(buf), s) == NULL && !buf[0]) { |
805 |
|
error(COMMAND, "no file"); |
806 |
|
return; |
807 |
|
} |