274 |
|
int ni_rows = 0; /* number of input rows */ |
275 |
|
int no_columns = 0; /* number of output columns */ |
276 |
|
int no_rows = 0; /* number of output rows */ |
277 |
+ |
int transpose = 0; /* transpose rows & cols? */ |
278 |
+ |
int i_header = 1; /* input header? */ |
279 |
+ |
int o_header = 1; /* output header? */ |
280 |
|
|
281 |
|
/* check settings and assign defaults */ |
282 |
|
static int |
296 |
|
return(0); |
297 |
|
} |
298 |
|
} |
299 |
+ |
if (transpose && (no_rows <= 0) & (no_columns <= 0)) { |
300 |
+ |
if (ni_rows > 0) no_columns = ni_rows; |
301 |
+ |
if (ni_columns > 0) no_rows = ni_columns; |
302 |
+ |
} else if ((no_rows <= 0) & (no_columns > 0) && |
303 |
+ |
!((ni_rows*ni_columns) % no_columns)) |
304 |
+ |
no_rows = ni_rows*ni_columns/no_columns; |
305 |
|
if (n_comp <= 0) |
306 |
|
n_comp = 3; |
307 |
|
return(1); |
475 |
|
n_comp = n; |
476 |
|
return(0); |
477 |
|
} |
478 |
< |
fputs(s, stdout); /* copy header info. */ |
478 |
> |
if (o_header) |
479 |
> |
fputs(s, stdout); /* copy header info. */ |
480 |
|
return(0); |
481 |
|
} |
482 |
|
|
484 |
|
int |
485 |
|
main(int argc, char *argv[]) |
486 |
|
{ |
477 |
– |
int i_header = 1; /* input header? */ |
478 |
– |
int o_header = 1; /* output header? */ |
479 |
– |
int transpose = 0; /* transpose rows & cols? */ |
487 |
|
int a; |
488 |
|
|
489 |
|
for (a = 1; a < argc && argv[a][0] == '-'; a++) |
572 |
|
SET_FILE_BINARY(stdout); |
573 |
|
} |
574 |
|
/* check for no-op */ |
575 |
< |
if (!transpose & (i_header == o_header) && (comp_size || |
575 |
> |
if (!transpose & !i_header & !o_header && (comp_size || |
576 |
|
(no_columns == ni_columns) & (no_rows == ni_rows))) { |
577 |
|
if (warnings) |
578 |
|
fprintf(stderr, "%s: no-op -- copying input verbatim\n", |
582 |
|
return(0); |
583 |
|
} |
584 |
|
if (i_header) { /* read header */ |
585 |
< |
if (getheader(stdin, &headline, NULL) < 0) |
585 |
> |
if (getheader(stdin, headline, NULL) < 0) |
586 |
|
return(1); |
587 |
|
if (!check_sizes()) |
588 |
|
return(1); |
594 |
|
return(1); |
595 |
|
if (o_header) { /* write header */ |
596 |
|
printargs(a, argv, stdout); |
590 |
– |
if (transpose && (no_rows <= 0) & (no_columns <= 0)) { |
591 |
– |
if (ni_rows > 0) no_columns = ni_rows; |
592 |
– |
if (ni_columns > 0) no_rows = ni_columns; |
593 |
– |
} |
597 |
|
if (no_rows > 0) |
598 |
|
printf("NROWS=%d\n", no_rows); |
599 |
|
if (no_columns > 0) |
617 |
|
} |
618 |
|
if (!do_transpose(&myMem)) |
619 |
|
return(1); |
620 |
< |
/* free_load(&myMem); */ |
621 |
< |
} else if (!do_resize(stdin)) /* just reshaping input */ |
620 |
> |
/* free_load(&myMem); about to exit, so don't bother */ |
621 |
> |
} else if (comp_size || (no_columns==ni_columns) & (no_rows==ni_rows)) { |
622 |
> |
if (!output_stream(stdin)) /* just changed header */ |
623 |
> |
return(1); |
624 |
> |
} else if (!do_resize(stdin)) /* reshaping input */ |
625 |
|
return(1); |
626 |
|
return(0); |
627 |
|
userr: |