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

Comparing ray/src/cal/rsplit.c (file contents):
Revision 1.7 by greg, Sat Jul 20 23:12:53 2019 UTC vs.
Revision 1.8 by greg, Mon Jul 22 18:01:03 2019 UTC

# Line 26 | Line 26 | static const char      *format[MAXFILE];
26   static int              termc[MAXFILE];
27   static int              nfiles = 0;
28  
29 static int      outheader = 0;          /* output header to each stream? */
30
29   static RESOLU   ourres = {PIXSTANDARD, 0, 0};
30  
31   static char     buf[16384];             /* input buffer used in scanOK() */
# Line 78 | Line 76 | scanOK(int termc)
76   int
77   main(int argc, char *argv[])
78   {
79 <        int             inpheader = 0;
80 <        int             inpres = 0;
83 <        int             outres = 0;
79 >        int             inpflags = 0;
80 >        int             needres = 0;
81          int             force = 0;
82          int             append = 0;
83          long            outcnt = 0;
# Line 101 | Line 98 | main(int argc, char *argv[])
98                          case 'i':
99                                  switch (argv[i][2]) {
100                                  case 'h':
101 <                                        inpheader = !inpheader;
101 >                                        inpflags ^= DOHEADER;
102                                          break;
103                                  case 'H':
104 <                                        inpres = !inpres;
104 >                                        inpflags ^= DORESOLU;
105                                          break;
106                                  default:
107                                          goto badopt;
108                                  }
109                                  break;
110                          case 'f':
111 <                                ++force;
115 <                                append = 0;
111 >                                force = !force;
112                                  break;
113                          case 'a':
114 <                                if (outheader | outres) {
119 <                                        fputs(argv[0], stderr);
120 <                                        fputs(": -a option incompatible with -oh and -oH\n",
121 <                                                        stderr);
122 <                                        return(1);
123 <                                }
124 <                                append = 1;
114 >                                append = !append;
115                                  break;
116                          case 'x':
117                                  ourres.xr = atoi(argv[++i]);
128                                outres = 1;
118                                  break;
119                          case 'y':
120                                  ourres.yr = atoi(argv[++i]);
132                                outres = 1;
121                                  break;
122                          case 'o':
123                                  switch (argv[i][2]) {
# Line 180 | Line 168 | main(int argc, char *argv[])
168                                  bininp += (curbytes > 0);
169                                  break;
170                          case '\0':
171 <                                outres |= (curflags & DORESOLU);
171 >                                needres |= (curflags & DORESOLU);
172                                  termc[nfiles] = curterm;
173                                  hdrflags[nfiles] = curflags;
174                                  output[nfiles] = stdout;
# Line 196 | Line 184 | main(int argc, char *argv[])
184                                  return(1);
185                          }
186                  } else if (argv[i][0] == '!') {
187 <                        outres |= (curflags & DORESOLU);
187 >                        needres |= (curflags & DORESOLU);
188                          termc[nfiles] = curterm;
189                          hdrflags[nfiles] = curflags;
190                          if ((output[nfiles] = popen(argv[i]+1, "w")) == NULL) {
# Line 209 | Line 197 | main(int argc, char *argv[])
197                          format[nfiles] = curfmt;
198                          bytsiz[nfiles++] = curbytes;
199                  } else {
200 <                        outres |= (curflags & DORESOLU);
200 >                        if (append & (curflags != 0)) {
201 >                                fputs(argv[0], stderr);
202 >                                fputs(": -a option incompatible with -oh and -oH\n",
203 >                                                stderr);
204 >                                return(1);
205 >                        }
206 >                        needres |= (curflags & DORESOLU);
207                          termc[nfiles] = curterm;
208                          hdrflags[nfiles] = curflags;
209                          if (!append & !force && access(argv[i], F_OK) == 0) {
# Line 248 | Line 242 | main(int argc, char *argv[])
242                  flockfile(output[i]);
243   #endif
244                                                  /* load/copy header */
245 <        if (inpheader && getheader(stdin, headline, NULL) < 0) {
245 >        if (inpflags & DOHEADER && getheader(stdin, headline, NULL) < 0) {
246                  fputs(argv[0], stderr);
247                  fputs(": cannot get header from standard input\n",
248                                  stderr);
249                  return(1);
250          }
251                                                  /* handle resolution string */
252 <        if (inpres && !fgetsresolu(&ourres, stdin)) {
252 >        if (inpflags & DORESOLU && !fgetsresolu(&ourres, stdin)) {
253                  fputs(argv[0], stderr);
254                  fputs(": cannot get resolution string from standard input\n",
255                                  stderr);
256                  return(1);
257          }
258 <        if (outres && (ourres.xr <= 0) | (ourres.yr <= 0)) {
258 >        if (needres && (ourres.xr <= 0) | (ourres.yr <= 0)) {
259                  fputs(argv[0], stderr);
260                  fputs(": -oH option requires -iH or -x and -y options\n", stderr);
261                  return(1);
# Line 277 | Line 271 | main(int argc, char *argv[])
271          }
272          for (i = 0; i < nfiles; i++) {          /* complete headers */
273                  if (hdrflags[i] & DOHEADER) {
274 <                        if (!inpheader)
274 >                        if (!(inpflags & DOHEADER))
275                                  newheader("RADIANCE", output[i]);
276                          printargs(argc, argv, output[i]);
277                          if (format[i] != NULL)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines