ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/px/pcomb.c
(Generate patch)

Comparing ray/src/px/pcomb.c (file contents):
Revision 1.14 by greg, Thu May 23 13:46:05 1991 UTC vs.
Revision 2.16 by greg, Mon Oct 16 12:04:33 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1991 Regents of the University of California */
1 > /* Copyright (c) 1992 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 10 | Line 10 | static char SCCSid[] = "$SunId$ LBL";
10   *      1/4/89
11   */
12  
13 < #include <stdio.h>
13 > #include "standard.h"
14  
15 #include <errno.h>
16
15   #include "color.h"
16  
17 + #include "resolu.h"
18 +
19   #include "calcomp.h"
20  
21 + #include "view.h"
22 +
23   #define MAXINP          32              /* maximum number of input files */
24 < #define WINSIZ          9               /* scanline window size */
25 < #define MIDSCN          4               /* current scan position */
24 > #define WINSIZ          17              /* scanline window size */
25 > #define MIDSCN          ((WINSIZ-1)/2+1)
26  
25 #define BRT             (-1)            /* special index for brightness */
26
27   struct {
28 <        char    *name;          /* file name */
28 >        char    *name;          /* file or command name */
29          FILE    *fp;            /* stream pointer */
30 +        VIEW    vw;             /* view for picture */
31 +        RESOLU  rs;             /* image resolution and orientation */
32          COLOR   *scan[WINSIZ];  /* input scanline window */
33          COLOR   coef;           /* coefficient */
34 +        COLOR   expos;          /* recorded exposure */
35   }       input[MAXINP];                  /* input pictures */
36  
37   int     nfiles;                         /* number of input files */
38  
39 < char    *vcolin[3] = {"ri", "gi", "bi"};
37 < char    *vcolout[3] = {"ro", "go", "bo"};
38 < #define vbrtin          "li"
39 < #define vbrtout         "lo"
39 > char    ourfmt[LPICFMT+1] = PICFMT;     /* input picture format */
40  
41 < #define vnfiles         "nfiles"
42 < #define vxres           "xres"
43 < #define vyres           "yres"
44 < #define vxpos           "x"
45 < #define vypos           "y"
41 > char    Command[] = "<Command>";
42 > char    vcolin[3][4] = {"ri", "gi", "bi"};
43 > char    vcolout[3][4] = {"ro", "go", "bo"};
44 > char    vbrtin[] = "li";
45 > char    vbrtout[] = "lo";
46 > char    vcolexp[3][4] = {"re", "ge", "be"};
47 > char    vbrtexp[] = "le";
48  
49 + char    vray[6][4] = {"Ox", "Oy", "Oz", "Dx", "Dy", "Dz"};
50 +
51 + char    vnfiles[] = "nfiles";
52 + char    vxmax[] = "xmax";
53 + char    vymax[] = "ymax";
54 + char    vxres[] = "xres";
55 + char    vyres[] = "yres";
56 + char    vxpos[] = "x";
57 + char    vypos[] = "y";
58 +
59   int     nowarn = 0;                     /* no warning messages? */
60  
61 < int     original = 0;                   /* origninal values? */
61 > int     xmax = 0, ymax = 0;             /* input resolution */
62  
63 < int     xres=0, yres=0;                 /* picture resolution */
63 > int     xscan, yscan;                   /* input position */
64  
65 < int     xpos, ypos;                     /* picture position */
65 > int     xres, yres;                     /* output resolution */
66  
67 < int     wrongformat = 0;
67 > int     xpos, ypos;                     /* output position */
68  
69 + char    *progname;                      /* global argv[0] */
70  
71 < tputs(s)                        /* put out string preceded by a tab */
72 < char    *s;
60 < {
61 <        char    fmt[32];
62 <        double  d;
63 <        COLOR   ctmp;
71 > int     wrongformat = 0;
72 > int     gotview;
73  
74 <        if (isformat(s)) {                      /* check format */
66 <                formatval(fmt, s);
67 <                wrongformat = strcmp(fmt, COLRFMT);
68 <        } else if (original && isexpos(s)) {    /* exposure */
69 <                d = 1.0/exposval(s);
70 <                scalecolor(input[nfiles].coef, d);
71 <        } else if (original && iscolcor(s)) {   /* color correction */
72 <                colcorval(ctmp, s);
73 <                colval(input[nfiles].coef,RED) /= colval(ctmp,RED);
74 <                colval(input[nfiles].coef,GRN) /= colval(ctmp,GRN);
75 <                colval(input[nfiles].coef,BLU) /= colval(ctmp,BLU);
76 <        } else {                                /* echo unaffected line */
77 <                putchar('\t');
78 <                fputs(s, stdout);
79 <        }
74 > FILE    *popen();
75  
76 < }
76 > extern char     *emalloc();
77  
78  
79   main(argc, argv)
80   int     argc;
81   char    *argv[];
82   {
83 <        extern double   l_redin(), l_grnin(), l_bluin(), l_brtin(), atof();
83 >        int     original;
84          double  f;
85          int     a, i;
86 <        
87 <        funset(vcolin[RED], 1, '=', l_redin);
88 <        funset(vcolin[GRN], 1, '=', l_grnin);
89 <        funset(vcolin[BLU], 1, '=', l_bluin);
90 <        funset(vbrtin, 1, '=', l_brtin);
91 <        
92 <        for (a = 1; a < argc; a++)
86 > #ifdef MSDOS
87 >        extern int  _fmode;
88 >        _fmode = O_BINARY;
89 >        setmode(fileno(stdin), O_BINARY);
90 >        setmode(fileno(stdout), O_BINARY);
91 > #endif
92 >        progname = argv[0];
93 >                                                /* scan options */
94 >        for (a = 1; a < argc; a++) {
95                  if (argv[a][0] == '-')
96                          switch (argv[a][1]) {
100                        case '\0':
101                        case 's':
102                        case 'c':
103                                goto getfiles;
97                          case 'x':
105                                xres = atoi(argv[++a]);
106                                break;
98                          case 'y':
99 <                                yres = atoi(argv[++a]);
100 <                                break;
99 >                                a++;
100 >                                continue;
101                          case 'w':
102                                  nowarn = !nowarn;
103 <                                break;
113 <                        case 'o':
114 <                                original = !original;
115 <                                break;
103 >                                continue;
104                          case 'f':
117                                fcompile(argv[++a]);
118                                break;
105                          case 'e':
106 <                                scompile(argv[++a], NULL, 0);
107 <                                break;
122 <                        default:
123 <                                goto usage;
106 >                                a++;
107 >                                continue;
108                          }
109 <                else
110 <                        break;
111 < getfiles:
112 <        for (nfiles = 0; nfiles < MAXINP; nfiles++)
109 >                break;
110 >        }
111 >        newheader("RADIANCE", stdout);  /* start header */
112 >                                        /* process files */
113 >        for (nfiles = 0; nfiles < MAXINP; nfiles++) {
114                  setcolor(input[nfiles].coef, 1.0, 1.0, 1.0);
115 +                setcolor(input[nfiles].expos, 1.0, 1.0, 1.0);
116 +                copystruct(&input[nfiles].vw, &stdview);
117 +        }
118          nfiles = 0;
119 +        original = 0;
120          for ( ; a < argc; a++) {
121                  if (nfiles >= MAXINP) {
122                          eputs(argv[0]);
# Line 140 | Line 129 | getfiles:
129                                  input[nfiles].name = "<stdin>";
130                                  input[nfiles].fp = stdin;
131                                  break;
132 +                        case 'o':
133 +                                original++;
134 +                                continue;
135                          case 's':
136                                  f = atof(argv[++a]);
137                                  scalecolor(input[nfiles].coef, f);
# Line 153 | Line 145 | getfiles:
145                                  goto usage;
146                          }
147                  else {
148 <                        input[nfiles].name = argv[a];
149 <                        input[nfiles].fp = fopen(argv[a], "r");
148 >                        if (argv[a][0] == '!') {
149 >                                input[nfiles].name = Command;
150 >                                input[nfiles].fp = popen(argv[a]+1, "r");
151 >                        } else {
152 >                                input[nfiles].name = argv[a];
153 >                                input[nfiles].fp = fopen(argv[a], "r");
154 >                        }
155                          if (input[nfiles].fp == NULL) {
156                                  perror(argv[a]);
157                                  quit(1);
158                          }
159                  }
160 <                fputs(input[nfiles].name, stdout);
161 <                fputs(":\n", stdout);
162 <                getheader(input[nfiles].fp, tputs, NULL);
163 <                if (wrongformat) {
164 <                        eputs(input[nfiles].name);
165 <                        eputs(": not in Radiance picture format\n");
166 <                        quit(1);
160 >                checkfile();
161 >                if (original) {
162 >                        colval(input[nfiles].coef,RED) /=
163 >                                        colval(input[nfiles].expos,RED);
164 >                        colval(input[nfiles].coef,GRN) /=
165 >                                        colval(input[nfiles].expos,GRN);
166 >                        colval(input[nfiles].coef,BLU) /=
167 >                                        colval(input[nfiles].expos,BLU);
168                  }
171                if (fgetresolu(&xpos, &ypos, input[nfiles].fp) !=
172                                (YMAJOR|YDECR)) {
173                        eputs(input[nfiles].name);
174                        eputs(": bad picture size\n");
175                        quit(1);
176                }
177                if (xres == 0 && yres == 0) {
178                        xres = xpos;
179                        yres = ypos;
180                } else if (xpos != xres || ypos != yres) {
181                        eputs(argv[0]);
182                        eputs(": resolution mismatch\n");
183                        quit(1);
184                }
185                for (i = 0; i < WINSIZ; i++)
186                        input[nfiles].scan[i] =
187                                        (COLOR *)emalloc(xres*sizeof(COLOR));
169                  nfiles++;
170 +                original = 0;
171          }
172 +        init();                         /* set constants */
173 +                                        /* go back and get expressions */
174 +        for (a = 1; a < argc; a++) {
175 +                if (argv[a][0] == '-')
176 +                        switch (argv[a][1]) {
177 +                        case 'x':
178 +                                varset(vxres, ':', eval(argv[++a]));
179 +                                continue;
180 +                        case 'y':
181 +                                varset(vyres, ':', eval(argv[++a]));
182 +                                continue;
183 +                        case 'w':
184 +                                continue;
185 +                        case 'f':
186 +                                fcompile(argv[++a]);
187 +                                continue;
188 +                        case 'e':
189 +                                scompile(argv[++a], NULL, 0);
190 +                                continue;
191 +                        }
192 +                break;
193 +        }
194 +                                                /* set/get output resolution */
195 +        if (!vardefined(vxres))
196 +                varset(vxres, ':', (double)xmax);
197 +        if (!vardefined(vyres))
198 +                varset(vyres, ':', (double)ymax);
199 +        xres = varvalue(vxres) + .5;
200 +        yres = varvalue(vyres) + .5;
201 +        if (xres <= 0 || yres <= 0) {
202 +                eputs(argv[0]);
203 +                eputs(": illegal output resolution\n");
204 +                quit(1);
205 +        }
206 +                                                /* complete header */
207          printargs(argc, argv, stdout);
208 <        fputformat(COLRFMT, stdout);
208 >        if (strcmp(ourfmt, PICFMT))
209 >                fputformat(ourfmt, stdout);     /* print format if known */
210          putchar('\n');
211 <        fputresolu(YMAJOR|YDECR, xres, yres, stdout);
211 >        fprtresolu(xres, yres, stdout);
212 >                                                /* combine pictures */
213          combine();
214          quit(0);
215   usage:
216          eputs("Usage: ");
217          eputs(argv[0]);
218          eputs(
219 < " [-w][-h][-x xr][-y yr][-e expr][-f file] [ [-s f][-c r g b] pic ..]\n");
219 > " [-w][-x xr][-y yr][-e expr][-f file] [ [-o][-s f][-c r g b] pic ..]\n");
220          quit(1);
221   }
222  
223  
224 + tputs(s)                        /* put out string preceded by a tab */
225 + char    *s;
226 + {
227 +        char    fmt[32];
228 +        double  d;
229 +        COLOR   ctmp;
230 +
231 +        if (isheadid(s))                        /* header id */
232 +                return;         /* don't echo */
233 +        if (formatval(fmt, s)) {                /* check format */
234 +                if (globmatch(ourfmt, fmt)) {
235 +                        wrongformat = 0;
236 +                        strcpy(ourfmt, fmt);
237 +                } else
238 +                        wrongformat = 1;
239 +                return;         /* don't echo */
240 +        }
241 +        if (isexpos(s)) {                       /* exposure */
242 +                d = exposval(s);
243 +                scalecolor(input[nfiles].expos, d);
244 +        } else if (iscolcor(s)) {               /* color correction */
245 +                colcorval(ctmp, s);
246 +                multcolor(input[nfiles].expos, ctmp);
247 +        } else if (isview(s) && sscanview(&input[nfiles].vw, s) > 0)
248 +                gotview++;
249 +                                                /* echo line */
250 +        putchar('\t');
251 +        fputs(s, stdout);
252 + }
253 +
254 +
255 + checkfile()                     /* ready a file */
256 + {
257 +        register int    i;
258 +                                        /* process header */
259 +        gotview = 0;
260 +        fputs(input[nfiles].name, stdout);
261 +        fputs(":\n", stdout);
262 +        getheader(input[nfiles].fp, tputs, NULL);
263 +        if (wrongformat) {
264 +                eputs(input[nfiles].name);
265 +                eputs(": not in Radiance picture format\n");
266 +                quit(1);
267 +        }
268 +        if (!gotview || setview(&input[nfiles].vw) != NULL)
269 +                input[nfiles].vw.type = 0;
270 +        if (!fgetsresolu(&input[nfiles].rs, input[nfiles].fp)) {
271 +                eputs(input[nfiles].name);
272 +                eputs(": bad picture size\n");
273 +                quit(1);
274 +        }
275 +        if (xmax == 0 && ymax == 0) {
276 +                xmax = scanlen(&input[nfiles].rs);
277 +                ymax = numscans(&input[nfiles].rs);
278 +        } else if (scanlen(&input[nfiles].rs) != xmax ||
279 +                        numscans(&input[nfiles].rs) != ymax) {
280 +                eputs(input[nfiles].name);
281 +                eputs(": resolution mismatch\n");
282 +                quit(1);
283 +        }
284 +                                        /* allocate scanlines */
285 +        for (i = 0; i < WINSIZ; i++)
286 +                input[nfiles].scan[i] = (COLOR *)emalloc(xmax*sizeof(COLOR));
287 + }
288 +
289 +
290 + double
291 + rgb_bright(clr)
292 + COLOR  clr;
293 + {
294 +        return(bright(clr));
295 + }
296 +
297 +
298 + double
299 + xyz_bright(clr)
300 + COLOR  clr;
301 + {
302 +        return(clr[CIEY]);
303 + }
304 +
305 +
306 + double  (*ourbright)() = rgb_bright;
307 +
308 +
309 + init()                                  /* perform final setup */
310 + {
311 +        double  l_colin(), l_expos(), l_ray();
312 +        register int    i;
313 +                                                /* define constants */
314 +        varset(vnfiles, ':', (double)nfiles);
315 +        varset(vxmax, ':', (double)xmax);
316 +        varset(vymax, ':', (double)ymax);
317 +                                                /* set functions */
318 +        for (i = 0; i < 3; i++) {
319 +                funset(vcolexp[i], 1, ':', l_expos);
320 +                funset(vcolin[i], 1, '=', l_colin);
321 +        }
322 +        funset(vbrtexp, 1, ':', l_expos);
323 +        funset(vbrtin, 1, '=', l_colin);
324 +        for (i = 0; i < 6; i++)
325 +                funset(vray[i], 1, '=', l_ray);
326 +                                                /* set brightness function */
327 +        if (!strcmp(ourfmt, CIEFMT))
328 +                ourbright = xyz_bright;
329 + }
330 +
331 +
332   combine()                       /* combine pictures */
333   {
334          EPNODE  *coldef[3], *brtdef;
# Line 219 | Line 346 | combine()                      /* combine pictures */
346                  brtdef = eparse(vbrtout);
347          else
348                  brtdef = NULL;
222                                                /* define constants */
223        varset(vnfiles, ':', (double)nfiles);
224        varset(vxres, ':', (double)xres);
225        varset(vyres, ':', (double)yres);
349                                                  /* allocate scanline */
350          scanout = (COLOR *)emalloc(xres*sizeof(COLOR));
351 <                                                /* initialize input */
352 <        initinp();
351 >                                                /* set input position */
352 >        yscan = ymax+MIDSCN;
353                                                  /* combine files */
354          for (ypos = yres-1; ypos >= 0; ypos--) {
355              advance();
356              varset(vypos, '=', (double)ypos);
357              for (xpos = 0; xpos < xres; xpos++) {
358 +                xscan = (long)xpos*xmax/xres;
359                  varset(vxpos, '=', (double)xpos);
360                  eclock++;
361                  if (brtdef != NULL) {
# Line 246 | Line 370 | combine()                      /* combine pictures */
370                          } else {
371                              d = 0.0;
372                              for (i = 0; i < nfiles; i++)
373 <                                d += colval(input[i].scan[MIDSCN][xpos],j);
373 >                                d += colval(input[i].scan[MIDSCN][xscan],j);
374                          }
375                          if (d < 0.0)
376                              d = 0.0;
# Line 263 | Line 387 | combine()                      /* combine pictures */
387   }
388  
389  
390 < initinp()                       /* initilize scan windows */
390 > advance()                       /* read in data for next scanline */
391   {
392 <        for (ypos = yres+(MIDSCN-1); ypos >= yres; ypos--)
393 <                advance();
392 >        int     ytarget;
393 >        register COLOR  *st;
394 >        register int    i, j;
395 >
396 >        for (ytarget = (long)ypos*ymax/yres; yscan > ytarget; yscan--)
397 >                for (i = 0; i < nfiles; i++) {
398 >                        st = input[i].scan[WINSIZ-1];
399 >                        for (j = WINSIZ-1; j > 0; j--)  /* rotate window */
400 >                                input[i].scan[j] = input[i].scan[j-1];
401 >                        input[i].scan[0] = st;
402 >                        if (yscan <= MIDSCN)            /* hit bottom? */
403 >                                continue;
404 >                        if (freadscan(st, xmax, input[i].fp) < 0) {  /* read */
405 >                                eputs(input[i].name);
406 >                                eputs(": read error\n");
407 >                                quit(1);
408 >                        }
409 >                        if (fabs(colval(input[i].coef,RED)-1.0) > 1e-3 ||
410 >                                fabs(colval(input[i].coef,GRN)-1.0) > 1e-3 ||
411 >                                fabs(colval(input[i].coef,BLU)-1.0) > 1e-3)
412 >                                for (j = 0; j < xmax; j++)  /* adjust color */
413 >                                        multcolor(st[j], input[i].coef);
414 >                }
415   }
416  
417  
418 < advance()                       /* read in next scanline */
418 > double
419 > l_expos(nam)                    /* return picture exposure */
420 > register char   *nam;
421   {
422 <        register COLOR  *st;
276 <        register int    i, j;
422 >        register int    fn, n;
423  
424 <        for (i = 0; i < nfiles; i++) {
425 <                st = input[i].scan[WINSIZ-1];
426 <                for (j = WINSIZ-1; j > 0; j--)  /* rotate window */
427 <                        input[i].scan[j] = input[i].scan[j-1];
428 <                input[i].scan[0] = st;
429 <                if (ypos < MIDSCN)              /* hit bottom */
430 <                        continue;
431 <                if (freadscan(st, xres, input[i].fp) < 0) {
432 <                        eputs(input[i].name);
433 <                        eputs(": read error\n");
434 <                        quit(1);
289 <                }
290 <                for (j = 0; j < xres; j++)      /* adjust color */
291 <                        multcolor(st[j], input[i].coef);
292 <        }
424 >        fn = argument(1) - .5;
425 >        if (fn < 0 || fn >= nfiles)
426 >                return(1.0);
427 >        if (nam == vbrtexp)
428 >                return((*ourbright)(input[fn].expos));
429 >        n = 3;
430 >        while (n--)
431 >                if (nam == vcolexp[n])
432 >                        return(colval(input[fn].expos,n));
433 >        eputs("Bad call to l_expos()!\n");
434 >        quit(1);
435   }
436  
437  
438   double
439 < colin(ci)                       /* return color value for picture */
440 < register int    ci;
439 > l_colin(nam)                    /* return color value for picture */
440 > register char   *nam;
441   {
442 <        int     n, fn;
443 <        register int    xoff, yoff;
442 >        int     fn;
443 >        register int    n, xoff, yoff;
444          double  d;
445  
446 <        fn = (d = argument(1)) - .5;
447 <        if (d <= -.5 || fn >= nfiles) {
446 >        d = argument(1);
447 >        if (d > -.5 && d < .5)
448 >                return((double)nfiles);
449 >        fn = d - .5;
450 >        if (fn < 0 || fn >= nfiles) {
451                  errno = EDOM;
452                  return(0.0);
453          }
309        if (d < .5)
310                return((double)nfiles);
454          xoff = yoff = 0;
455          n = nargum();
456          if (n >= 2) {
457                  d = argument(2);
458                  if (d < 0.0) {
459                          xoff = d-.5;
460 <                        if (xpos+xoff < 0)
461 <                                xoff = -xpos;
460 >                        if (xscan+xoff < 0)
461 >                                xoff = -xscan;
462                  } else {
463                          xoff = d+.5;
464 <                        if (xpos+xoff >= xres)
465 <                                xoff = xres-1-xpos;
464 >                        if (xscan+xoff >= xmax)
465 >                                xoff = xmax-1-xscan;
466                  }
467          }
468          if (n >= 3) {
# Line 328 | Line 471 | register int   ci;
471                          yoff = d-.5;
472                          if (yoff+MIDSCN < 0)
473                                  yoff = -MIDSCN;
474 <                        if (ypos+yoff < 0)
475 <                                yoff = -ypos;
474 >                        if (yscan+yoff < 0)
475 >                                yoff = -yscan;
476                  } else {
477                          yoff = d+.5;
478                          if (yoff+MIDSCN >= WINSIZ)
479                                  yoff = WINSIZ-1-MIDSCN;
480 <                        if (ypos+yoff >= yres)
481 <                                yoff = yres-1-ypos;
480 >                        if (yscan+yoff >= ymax)
481 >                                yoff = ymax-1-yscan;
482                  }
483          }
484 <        if (ci == BRT)
485 <                return(bright(input[fn].scan[MIDSCN+yoff][xpos+xoff]));
486 <        return(colval(input[fn].scan[MIDSCN+yoff][xpos+xoff],ci));
484 >        if (nam == vbrtin)
485 >                return((*ourbright)(input[fn].scan[MIDSCN+yoff][xscan+xoff]));
486 >        n = 3;
487 >        while (n--)
488 >            if (nam == vcolin[n])
489 >                return(colval(input[fn].scan[MIDSCN+yoff][xscan+xoff],n));
490 >        eputs("Bad call to l_colin()!\n");
491 >        quit(1);
492   }
493  
494  
495   double
496 < l_redin()                       /* get red color */
496 > l_ray(nam)              /* return ray origin or direction */
497 > register char   *nam;
498   {
499 <        return(colin(RED));
500 < }
499 >        static unsigned long    ltick[MAXINP];
500 >        static FVECT    lorg[MAXINP], ldir[MAXINP];
501 >        FLOAT   loc[2];
502 >        double  d;
503 >        int     fn;
504 >        register int    i;
505  
506 <
507 < double
508 < l_grnin()                       /* get green color */
509 < {
510 <        return(colin(GRN));
506 >        d = argument(1);
507 >        if (d > -.5 && d < .5)
508 >                return((double)nfiles);
509 >        fn = d - .5;
510 >        if (fn < 0 || fn >= nfiles) {
511 >                errno = EDOM;
512 >                return(0.0);
513 >        }
514 >        if (ltick[fn] < eclock) {               /* need to compute? */
515 >                lorg[fn][0] = lorg[fn][1] = lorg[fn][2] = 0.0;
516 >                ldir[fn][0] = ldir[fn][1] = ldir[fn][2] = 0.0;
517 >                if (input[fn].vw.type == 0)
518 >                        errno = EDOM;
519 >                else {
520 >                        pix2loc(loc, &input[fn].rs, xscan, ymax-1-yscan);
521 >                        if (viewray(lorg[fn], ldir[fn],
522 >                                        &input[fn].vw, loc[0], loc[1]) < 0)
523 >                                errno = ERANGE;
524 >                }
525 >                ltick[fn] = eclock;
526 >        }
527 >        i = 6;
528 >        while (i--)
529 >                if (nam == vray[i])
530 >                        return(i < 3 ? lorg[fn][i] : ldir[fn][i-3]);
531 >        eputs("Bad call to l_ray()!\n");
532 >        quit(1);
533   }
534  
535  
361 double
362 l_bluin()                       /* get blue color */
363 {
364        return(colin(BLU));
365 }
366
367
368 double
369 l_brtin()                       /* get brightness value */
370 {
371        return(colin(BRT));
372 }
373
374
536   wputs(msg)
537   char    *msg;
538   {
# Line 387 | Line 548 | char   *msg;
548   }
549  
550  
551 < quit(code)
552 < int     code;
551 > quit(code)              /* exit gracefully */
552 > int  code;
553   {
554 +        register int  i;
555 +                                /* close input files */
556 +        for (i = 0; i < nfiles; i++)
557 +                if (input[i].name == Command)
558 +                        pclose(input[i].fp);
559 +                else
560 +                        fclose(input[i].fp);
561          exit(code);
562   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines