ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/radcompare.c
(Generate patch)

Comparing ray/src/util/radcompare.c (file contents):
Revision 2.22 by greg, Sat Aug 24 02:22:02 2019 UTC vs.
Revision 2.26 by greg, Mon Jul 27 16:49:56 2020 UTC

# Line 35 | Line 35 | double max_lim = 0.25;         /* difference limit if non-neg
35  
36   int     lin1cnt=0, lin2cnt=0;   /* file line position */
37  
38 + int     comment_c = '\0';       /* comment delimiter for text files */
39 +
40   const char      nsuffix[10][3] = {              /* 1st, 2nd, 3rd, etc. */
41                          "th","st","nd","rd","th","th","th","th","th","th"
42                  };
# Line 111 | Line 113 | usage()
113   {
114          fputs("Usage: ", stderr);
115          fputs(progname, stderr);
116 <        fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
116 >        fputs(" [-h][-c#][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n",
117                          stderr);
118          exit(2);
119   }
# Line 149 | Line 151 | read_line(LINEBUF *bp, FILE *fp)
151                  if (!bp->str)
152                          goto memerr;
153          }
154 +        if (comment_c) {                /* elide comment? */
155 +                char    *cp = sskip2(bp->str,0);
156 +                if (*cp == comment_c) {
157 +                        *cp++ = '\n';
158 +                        *cp = '\0';
159 +                        bp->len = cp - bp->str;
160 +                }
161 +        }
162          return(bp->len);
163   memerr:
164          fprintf(stderr,
# Line 317 | Line 327 | equiv_string(char *s1, char *s2)
327   static int
328   setheadvar(char *val, void *p)
329   {
330 +        char    newval[128];
331          LUTAB   *htp = (LUTAB *)p;
332          LUENT   *tep;
333          char    *key;
# Line 359 | Line 370 | setheadvar(char *val, void *p)
370                  return(-1);     /* memory allocation error */
371          if (!tep->key)
372                  tep->key = strcpy(malloc(kln+1), key);
373 <        if (tep->data)
373 >        if (tep->data) {        /* check for special cases */
374 >                if (!strcmp(key, "EXPOSURE")) {
375 >                        sprintf(newval, "%f", atof(tep->data)*atof(val));
376 >                        vln = strlen(val = newval);
377 >                }
378                  free(tep->data);
379 +        }
380          tep->data = strcpy(malloc(vln+1), val);
381          return(1);
382   }
# Line 469 | Line 485 | identify_type(const char *name, FILE *fin, LUTAB *htp)
485          }
486          if (c)
487                  return(TYP_BINARY);
472        SET_FILE_TEXT(fin);                     /* originally set to binary */
488          return(TYP_TEXT);
489   badeof:
490          if (report != REP_QUIET) {
# Line 552 | Line 567 | compare_text()
567  
568          if (report >= REP_VERBOSE) {
569                  fputs(progname, stdout);
570 <                fputs(": comparing inputs as ASCII text\n", stdout);
570 >                fputs(": comparing inputs as ASCII text", stdout);
571 >                if (comment_c) {
572 >                        fputs(", ignoring comments starting with '", stdout);
573 >                        fputc(comment_c, stdout);
574 >                        fputc('\'', stdout);
575 >                }
576 >                fputc('\n', stdout);
577          }
578 +        SET_FILE_TEXT(f1in);                    /* originally set to binary */
579 +        SET_FILE_TEXT(f2in);
580          init_line(&l1buf); init_line(&l2buf);   /* compare a line at a time */
581          while (read_line(&l1buf, f1in)) {
582                  lin1cnt++;
# Line 696 | Line 719 | set_refdepth(DEPTHCODEC *dcp, LUTAB *htp)
719          static char     depthvar[] = DEPTHSTR;
720          const char      *drval;
721  
722 <        depthvar[LDEPTHSTR] = '\0';
722 >        depthvar[LDEPTHSTR-1] = '\0';
723          drval = (const char *)lu_find(htp, depthvar)->data;
724          if (!drval)
725                  return(0);
# Line 892 | Line 915 | main(int argc, char *argv[])
915                  switch (argv[a][1]) {
916                  case 'h':                       /* ignore header info. */
917                          ign_header = !ign_header;
918 +                        continue;
919 +                case 'c':                       /* ignore comments */
920 +                        comment_c = argv[a][2];
921                          continue;
922                  case 's':                       /* silent operation */
923                          report = REP_QUIET;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines