--- ray/src/util/rcollate.c 2022/03/16 19:25:25 2.42 +++ ray/src/util/rcollate.c 2024/01/26 00:47:17 2.45 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcollate.c,v 2.42 2022/03/16 19:25:25 greg Exp $"; +static const char RCSid[] = "$Id: rcollate.c,v 2.45 2024/01/26 00:47:17 greg Exp $"; #endif /* * Utility to re-order records in a binary or ASCII data file (matrix) @@ -613,10 +613,13 @@ headline(char *s, void *p) int n; if (formatval(fmt, s)) { + if (fmtid == fmt) return(0); if (fmtid == NULL) { fmtid = fmt; return(0); } + if (!check & (comp_size == 1) & (n_comp > 1)) + return(0); /* byte exception - skip check */ if (!strcmp(fmt, fmtid)) return(0); fprintf(stderr, "Input format '%s' != '%s'\n", fmt, fmtid); @@ -641,6 +644,8 @@ headline(char *s, void *p) return(0); } if (!strncmp(s, "NCOMP=", 6)) { + if (!check & (comp_size == 1) & (n_comp > 1)) + return(0); /* byte exception - ignore */ n = atoi(s+6); if ((n_comp > 0) & (n != n_comp)) { fputs("Incorrect number of components\n", stderr); @@ -763,20 +768,18 @@ main(int argc, char *argv[]) argv[0]); return(!output_stream(stdin)); } - if (i_header) { /* read header */ - if (getheader(stdin, headline, NULL) < 0) - return(1); - if (!check_sizes()) - return(1); - } else if (!check_sizes()) + /* read input header? */ + if (i_header && getheader(stdin, headline, NULL) < 0) return(1); - if (o_header) { /* write/add to header */ + if (!check_sizes()) /* adjust sizes */ + return(1); + if (o_header) { /* add to output header? */ if (!i_header) newheader("RADIANCE", stdout); printargs(a, argv, stdout); printf("NCOMP=%d\n", n_comp); } - if (!comp_size) { /* a little late... */ + if (!comp_size) { /* a little late, here... */ SET_FILE_TEXT(stdin); SET_FILE_TEXT(stdout); }