276 |
|
int no_rows = 0; /* number of output rows */ |
277 |
|
|
278 |
|
/* check settings and assign defaults */ |
279 |
< |
static void |
279 |
> |
static int |
280 |
|
check_sizes() |
281 |
|
{ |
282 |
|
if (fmtid == NULL) { |
288 |
|
comp_size = sizeof(double); |
289 |
|
else if (!strcmp(fmtid, "byte")) |
290 |
|
comp_size = 1; |
291 |
+ |
else { |
292 |
+ |
fprintf(stderr, "Unsupported format: %s\n", fmtid); |
293 |
+ |
return(0); |
294 |
+ |
} |
295 |
|
} |
296 |
|
if (n_comp <= 0) |
297 |
|
n_comp = 3; |
298 |
+ |
return(1); |
299 |
|
} |
300 |
|
|
301 |
|
/* output transposed ASCII or binary data from memory */ |
372 |
|
int columns2go = no_columns; |
373 |
|
char word[256]; |
374 |
|
/* sanity checks */ |
375 |
< |
if (comp_size) { |
376 |
< |
fputs("Bad call to do_resize (binary input)\n", stderr); |
372 |
< |
return(0); |
373 |
< |
} |
375 |
> |
if (comp_size) |
376 |
> |
return(output_stream(fp)); /* binary data -- just copy */ |
377 |
|
if (no_columns <= 0) { |
378 |
|
fprintf(stderr, "Missing -oc specification\n"); |
379 |
|
return(0); |
564 |
|
SET_FILE_BINARY(stdout); |
565 |
|
} |
566 |
|
/* check for no-op */ |
567 |
< |
if (!transpose && (comp_size || |
567 |
> |
if (!transpose & (i_header == o_header) && (comp_size || |
568 |
|
(no_columns == ni_columns) & (no_rows == ni_rows))) { |
569 |
|
if (warnings) |
570 |
|
fprintf(stderr, "%s: no-op -- copying input verbatim\n", |
576 |
|
if (i_header) { /* read header */ |
577 |
|
if (getheader(stdin, &headline, NULL) < 0) |
578 |
|
return(1); |
579 |
< |
check_sizes(); |
579 |
> |
if (!check_sizes()) |
580 |
> |
return(1); |
581 |
|
if (comp_size) { /* a little late... */ |
582 |
|
SET_FILE_BINARY(stdin); |
583 |
|
SET_FILE_BINARY(stdout); |
584 |
|
} |
585 |
< |
} else |
586 |
< |
check_sizes(); |
585 |
> |
} else if (!check_sizes()) |
586 |
> |
return(1); |
587 |
|
if (o_header) { /* write header */ |
588 |
|
printargs(argc, argv, stdout); |
589 |
|
if (transpose && (no_rows <= 0) & (no_columns <= 0)) { |