--- ray/src/util/radcompare.c 2020/07/09 17:29:04 2.25 +++ ray/src/util/radcompare.c 2020/07/27 16:49:56 2.26 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: radcompare.c,v 2.25 2020/07/09 17:29:04 greg Exp $"; +static const char RCSid[] = "$Id: radcompare.c,v 2.26 2020/07/27 16:49:56 greg Exp $"; #endif /* * Compare Radiance files for significant differences @@ -35,6 +35,8 @@ double max_lim = 0.25; /* difference limit if non-neg int lin1cnt=0, lin2cnt=0; /* file line position */ +int comment_c = '\0'; /* comment delimiter for text files */ + const char nsuffix[10][3] = { /* 1st, 2nd, 3rd, etc. */ "th","st","nd","rd","th","th","th","th","th","th" }; @@ -111,7 +113,7 @@ usage() { fputs("Usage: ", stderr); fputs(progname, stderr); - fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n", + fputs(" [-h][-c#][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n", stderr); exit(2); } @@ -149,6 +151,14 @@ read_line(LINEBUF *bp, FILE *fp) if (!bp->str) goto memerr; } + if (comment_c) { /* elide comment? */ + char *cp = sskip2(bp->str,0); + if (*cp == comment_c) { + *cp++ = '\n'; + *cp = '\0'; + bp->len = cp - bp->str; + } + } return(bp->len); memerr: fprintf(stderr, @@ -557,7 +567,13 @@ compare_text() if (report >= REP_VERBOSE) { fputs(progname, stdout); - fputs(": comparing inputs as ASCII text\n", stdout); + fputs(": comparing inputs as ASCII text", stdout); + if (comment_c) { + fputs(", ignoring comments starting with '", stdout); + fputc(comment_c, stdout); + fputc('\'', stdout); + } + fputc('\n', stdout); } SET_FILE_TEXT(f1in); /* originally set to binary */ SET_FILE_TEXT(f2in); @@ -899,6 +915,9 @@ main(int argc, char *argv[]) switch (argv[a][1]) { case 'h': /* ignore header info. */ ign_header = !ign_header; + continue; + case 'c': /* ignore comments */ + comment_c = argv[a][2]; continue; case 's': /* silent operation */ report = REP_QUIET;