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.15 by greg, Fri May 24 14:46:14 1991 UTC vs.
Revision 1.16 by greg, Fri May 24 15:47:53 1991 UTC

# Line 81 | Line 81 | char   *argv[];
81                                  continue;
82                          case 'f':
83                          case 'e':
84 +                                a++;
85                                  continue;
86                          }
87                  break;
# Line 121 | Line 122 | char   *argv[];
122                                  quit(1);
123                          }
124                  }
125 +                checkfile();
126                  nfiles++;
127          }
128 <        initfiles();            /* initialize files and variables */
128 >        init();                         /* set constant expressions */
129                                          /* go back and get expressions */
130          for (a = 1; a < argc; a++) {
131                  if (argv[a][0] == '-')
132                          switch (argv[a][1]) {
133                          case 'x':
134                          case 'y':
135 +                                a++;
136 +                                continue;
137                          case 'w':
138                          case 'o':
139                                  continue;
# Line 181 | Line 185 | char   *s;
185                  putchar('\t');
186                  fputs(s, stdout);
187          }
188 + }
189  
190 +
191 + checkfile()                     /* ready a file */
192 + {
193 +        register int    i;
194 +                                        /* process header */
195 +        fputs(input[nfiles].name, stdout);
196 +        fputs(":\n", stdout);
197 +        getheader(input[nfiles].fp, tputs, NULL);
198 +        if (wrongformat) {
199 +                eputs(input[nfiles].name);
200 +                eputs(": not in Radiance picture format\n");
201 +                quit(1);
202 +        }
203 +        if (fgetresolu(&xpos, &ypos, input[nfiles].fp) != (YMAJOR|YDECR)) {
204 +                eputs(input[nfiles].name);
205 +                eputs(": bad picture size\n");
206 +                quit(1);
207 +        }
208 +        if (xres == 0 && yres == 0) {
209 +                xres = xpos;
210 +                yres = ypos;
211 +        } else if (xpos != xres || ypos != yres) {
212 +                eputs(input[nfiles].name);
213 +                eputs(": resolution mismatch\n");
214 +                quit(1);
215 +        }
216 +                                        /* allocate scanlines */
217 +        for (i = 0; i < WINSIZ; i++)
218 +                input[nfiles].scan[i] = (COLOR *)emalloc(xres*sizeof(COLOR));
219   }
220  
221  
222 < initfiles()                     /* ready files and set variables */
222 > init()                          /* perform final setup */
223   {
224          double  l_colin(), l_coef();
225 <        register int    n, i;
192 <                                        /* process picture headers */
193 <        for (n = 0; n < nfiles; n++) {
194 <                fputs(input[n].name, stdout);
195 <                fputs(":\n", stdout);
196 <                getheader(input[n].fp, tputs, NULL);
197 <                if (wrongformat) {
198 <                        eputs(input[n].name);
199 <                        eputs(": not in Radiance picture format\n");
200 <                        quit(1);
201 <                }
202 <                if (fgetresolu(&xpos, &ypos, input[n].fp) != (YMAJOR|YDECR)) {
203 <                        eputs(input[n].name);
204 <                        eputs(": bad picture size\n");
205 <                        quit(1);
206 <                }
207 <                if (xres == 0 && yres == 0) {
208 <                        xres = xpos;
209 <                        yres = ypos;
210 <                } else if (xpos != xres || ypos != yres) {
211 <                        eputs(input[n].name);
212 <                        eputs(": resolution mismatch\n");
213 <                        quit(1);
214 <                }
215 <                for (i = 0; i < WINSIZ; i++)
216 <                        input[n].scan[i] = (COLOR *)emalloc(xres*sizeof(COLOR));
217 <        }
225 >        register int    i;
226                                                  /* prime input */
227          for (ypos = yres+(MIDSCN-1); ypos >= yres; ypos--)
228                  advance();
# Line 317 | Line 325 | register char  *nam;
325          register int    fn, n;
326          double  d;
327  
328 <        fn = (d = argument(1)) - .5;
329 <        if (d <= -.5 || fn >= nfiles) {
328 >        d = argument(1);
329 >        if (d > -.5 && d < .5)
330 >                return((double)nfiles);
331 >        fn = d - .5;
332 >        if (fn < 0 || fn >= nfiles) {
333                  errno = EDOM;
334                  return(0.0);
335          }
325        if (d < .5)
326                return((double)nfiles);
336          if (nam == vbrtcoef)
337                  return(bright(input[fn].coef));
338          n = 3;
# Line 343 | Line 352 | register char  *nam;
352          register int    n, xoff, yoff;
353          double  d;
354  
355 <        fn = (d = argument(1)) - .5;
356 <        if (d <= -.5 || fn >= nfiles) {
355 >        d = argument(1);
356 >        if (d > -.5 && d < .5)
357 >                return((double)nfiles);
358 >        fn = d - .5;
359 >        if (fn < 0 || fn >= nfiles) {
360                  errno = EDOM;
361                  return(0.0);
362          }
351        if (d < .5)
352                return((double)nfiles);
363          xoff = yoff = 0;
364          n = nargum();
365          if (n >= 2) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines