19 |
|
|
20 |
|
#define MAXFILE 512 /* maximum number of files */ |
21 |
|
|
22 |
+ |
static int swapped = 0; /* input is byte-swapped */ |
23 |
+ |
|
24 |
|
static FILE *output[MAXFILE]; |
25 |
|
static int bytsiz[MAXFILE]; |
26 |
|
static short hdrflags[MAXFILE]; |
38 |
|
headline(char *s, void *p) |
39 |
|
{ |
40 |
|
extern const char FMTSTR[]; |
41 |
< |
int i = nfiles; |
41 |
> |
int i; |
42 |
|
|
43 |
|
if (strstr(s, FMTSTR) == s) |
44 |
|
return(0); /* don't copy format */ |
48 |
|
return(0); |
49 |
|
if (!strncmp(s, "NCOMP=", 6)) |
50 |
|
return(0); |
51 |
+ |
if ((i = isbigendian(s)) >= 0) { |
52 |
+ |
swapped = (nativebigendian() != i); |
53 |
+ |
return(0); |
54 |
+ |
} |
55 |
+ |
i = nfiles; |
56 |
|
while (i--) /* else copy line to output streams */ |
57 |
|
if (hdrflags[i] & DOHEADER) |
58 |
|
fputs(s, output[i]); |
64 |
|
static int |
65 |
|
scanOK(int termc) |
66 |
|
{ |
67 |
+ |
int skip_white = (termc == ' '); |
68 |
|
char *cp = buf; |
69 |
|
int c; |
70 |
|
|
71 |
|
while ((c = getchar()) != EOF) { |
72 |
+ |
if (skip_white && isspace(c)) |
73 |
+ |
continue; |
74 |
+ |
skip_white = 0; |
75 |
+ |
if (c == '\n' && isspace(termc)) |
76 |
+ |
c = termc; /* forgiving assumption */ |
77 |
|
*cp++ = c; |
78 |
|
if (cp-buf >= sizeof(buf)) |
79 |
|
break; |
80 |
< |
if (c == termc) { |
80 |
> |
if ((termc == ' ') ? isspace(c) : (c == termc)) { |
81 |
|
*cp = '\0'; |
82 |
|
return(cp-buf); |
83 |
|
} |
287 |
|
if (!(inpflags & DOHEADER)) |
288 |
|
newheader("RADIANCE", output[i]); |
289 |
|
printargs(argc, argv, output[i]); |
290 |
< |
if (format[i] != NULL) |
290 |
> |
if (format[i] != NULL) { |
291 |
> |
extern const char BIGEND[]; |
292 |
> |
if ((format[i][0] == 'f') | |
293 |
> |
(format[i][0] == 'd')) { |
294 |
> |
fputs(BIGEND, output[i]); |
295 |
> |
fputs(nativebigendian() ^ swapped ? |
296 |
> |
"1\n" : "0\n", output[i]); |
297 |
> |
} |
298 |
|
fputformat(format[i], output[i]); |
299 |
+ |
} |
300 |
|
fputc('\n', output[i]); |
301 |
|
} |
302 |
|
if (hdrflags[i] & DORESOLU) |