| 96 |
|
int append = 0; |
| 97 |
|
long outcnt = 0; |
| 98 |
|
int bininp = 0; |
| 99 |
+ |
int nstdoutcomp = 0; |
| 100 |
|
int curterm = '\n'; |
| 101 |
|
int curncomp = 1; |
| 102 |
|
int curbytes = 0; |
| 182 |
|
} |
| 183 |
|
bininp += (curbytes > 0); |
| 184 |
|
break; |
| 185 |
< |
case '\0': |
| 186 |
< |
needres |= (curflags & DORESOLU); |
| 187 |
< |
termc[nfiles] = curterm; |
| 188 |
< |
hdrflags[nfiles] = curflags; |
| 185 |
> |
case '\0': /* stdout */ |
| 186 |
> |
if (!nstdoutcomp) { /* first use? */ |
| 187 |
> |
needres |= (curflags & DORESOLU); |
| 188 |
> |
hdrflags[nfiles] = curflags; |
| 189 |
> |
} |
| 190 |
|
output[nfiles] = stdout; |
| 191 |
|
if (curbytes > 0) |
| 192 |
|
SET_FILE_BINARY(output[nfiles]); |
| 193 |
+ |
termc[nfiles] = curterm; |
| 194 |
|
format[nfiles] = curfmt; |
| 195 |
< |
ncomp[nfiles] = curncomp; |
| 195 |
> |
nstdoutcomp += |
| 196 |
> |
ncomp[nfiles] = curncomp; |
| 197 |
|
bytsiz[nfiles++] = curbytes; |
| 198 |
|
break; |
| 199 |
|
badopt:; |
| 210 |
|
bytsiz[nfiles++] = curbytes; |
| 211 |
|
} else if (argv[i][0] == '!') { |
| 212 |
|
needres |= (curflags & DORESOLU); |
| 209 |
– |
termc[nfiles] = curterm; |
| 213 |
|
hdrflags[nfiles] = curflags; |
| 214 |
+ |
termc[nfiles] = curterm; |
| 215 |
|
if ((output[nfiles] = popen(argv[i]+1, "w")) == NULL) { |
| 216 |
|
fputs(argv[i], stderr); |
| 217 |
|
fputs(": cannot start command\n", stderr); |
| 230 |
|
return(1); |
| 231 |
|
} |
| 232 |
|
needres |= (curflags & DORESOLU); |
| 229 |
– |
termc[nfiles] = curterm; |
| 233 |
|
hdrflags[nfiles] = curflags; |
| 234 |
+ |
termc[nfiles] = curterm; |
| 235 |
|
if (!append & !force && access(argv[i], F_OK) == 0) { |
| 236 |
|
fputs(argv[i], stderr); |
| 237 |
|
fputs(": file exists -- use -f to overwrite\n", |
| 267 |
|
flockfile(stdin); |
| 268 |
|
for (i = nfiles; i--; ) |
| 269 |
|
if (output[i] != NULL) |
| 270 |
< |
flockfile(output[i]); |
| 270 |
> |
ftrylockfile(output[i]); |
| 271 |
|
#endif |
| 272 |
|
/* load/copy header */ |
| 273 |
|
if (inpflags & DOHEADER && getheader(stdin, headline, NULL) < 0) { |
| 274 |
|
fputs(argv[0], stderr); |
| 275 |
< |
fputs(": cannot get header from standard input\n", |
| 275 |
> |
fputs(": cannot read header from standard input\n", |
| 276 |
|
stderr); |
| 277 |
|
return(1); |
| 278 |
|
} |
| 279 |
|
/* handle resolution string */ |
| 280 |
|
if (inpflags & DORESOLU && !fgetsresolu(&ourres, stdin)) { |
| 281 |
|
fputs(argv[0], stderr); |
| 282 |
< |
fputs(": cannot get resolution string from standard input\n", |
| 279 |
< |
stderr); |
| 282 |
> |
fputs(": bad resolution string on standard input\n", stderr); |
| 283 |
|
return(1); |
| 284 |
|
} |
| 285 |
|
if (needres && (ourres.xr <= 0) | (ourres.yr <= 0)) { |
| 301 |
|
if (!(inpflags & DOHEADER)) |
| 302 |
|
newheader("RADIANCE", output[i]); |
| 303 |
|
printargs(argc, argv, output[i]); |
| 304 |
< |
fprintf(output[i], "NCOMP=%d\n", ncomp[i]); |
| 304 |
> |
fprintf(output[i], "NCOMP=%d\n", output[i]==stdout ? |
| 305 |
> |
nstdoutcomp : ncomp[i]); |
| 306 |
|
if (format[i] != NULL) { |
| 307 |
|
extern const char BIGEND[]; |
| 308 |
< |
if ((format[i][0] == 'f') | |
| 305 |
< |
(format[i][0] == 'd')) { |
| 308 |
> |
if (format[i][0] != 'a') { |
| 309 |
|
fputs(BIGEND, output[i]); |
| 310 |
|
fputs(nativebigendian() ^ swapped ? |
| 311 |
|
"1\n" : "0\n", output[i]); |