102 |
|
int curbytes = 0; |
103 |
|
int curflags = 0; |
104 |
|
const char *curfmt = "ascii"; |
105 |
< |
int i; |
105 |
> |
short outndx[MAXFILE]; |
106 |
> |
int i; |
107 |
|
|
108 |
+ |
memset(outndx, 0, sizeof(outndx)); |
109 |
|
for (i = 1; i < argc; i++) { |
110 |
|
if (argv[i][0] == '-') { |
111 |
|
switch (argv[i][1]) { |
196 |
|
format[nfiles] = curfmt; |
197 |
|
nstdoutcomp += |
198 |
|
ncomp[nfiles] = curncomp; |
199 |
< |
bytsiz[nfiles++] = curbytes; |
199 |
> |
bytsiz[nfiles] = curbytes; |
200 |
> |
outndx[nfiles++] = i; |
201 |
|
break; |
202 |
|
badopt:; |
203 |
|
default: |
210 |
|
termc[nfiles] = curterm; |
211 |
|
format[nfiles] = curfmt; |
212 |
|
ncomp[nfiles] = curncomp; |
213 |
< |
bytsiz[nfiles++] = curbytes; |
213 |
> |
bytsiz[nfiles] = curbytes; |
214 |
> |
outndx[nfiles++] = i; |
215 |
|
} else if (argv[i][0] == '!') { |
216 |
|
needres |= (curflags & DORESOLU); |
217 |
|
hdrflags[nfiles] = curflags; |
225 |
|
SET_FILE_BINARY(output[nfiles]); |
226 |
|
format[nfiles] = curfmt; |
227 |
|
ncomp[nfiles] = curncomp; |
228 |
< |
bytsiz[nfiles++] = curbytes; |
228 |
> |
bytsiz[nfiles] = curbytes; |
229 |
> |
outndx[nfiles++] = i; |
230 |
|
} else { |
231 |
+ |
int j = nfiles; |
232 |
+ |
while (j--) /* check duplicates */ |
233 |
+ |
if (!strcmp(argv[i], argv[outndx[j]])) { |
234 |
+ |
fputs(argv[0], stderr); |
235 |
+ |
fputs(": duplicate output: ", stderr); |
236 |
+ |
fputs(argv[i], stderr); |
237 |
+ |
fputc('\n', stderr); |
238 |
+ |
return(1); |
239 |
+ |
} |
240 |
|
if (append & (curflags != 0)) { |
241 |
|
fputs(argv[0], stderr); |
242 |
|
fputs(": -a option incompatible with -oh and -oH\n", |
262 |
|
SET_FILE_BINARY(output[nfiles]); |
263 |
|
format[nfiles] = curfmt; |
264 |
|
ncomp[nfiles] = curncomp; |
265 |
< |
bytsiz[nfiles++] = curbytes; |
265 |
> |
bytsiz[nfiles] = curbytes; |
266 |
> |
outndx[nfiles++] = i; |
267 |
|
} |
268 |
|
if (nfiles >= MAXFILE) { |
269 |
|
fputs(argv[0], stderr); |
320 |
|
nstdoutcomp : ncomp[i]); |
321 |
|
if (format[i] != NULL) { |
322 |
|
extern const char BIGEND[]; |
323 |
< |
if (format[i][0] != 'a') { |
323 |
> |
if (bytsiz[i] > 1) { |
324 |
|
fputs(BIGEND, output[i]); |
325 |
|
fputs(nativebigendian() ^ swapped ? |
326 |
|
"1\n" : "0\n", output[i]); |