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.26 by greg, Mon Jul 27 16:49:56 2020 UTC vs.
Revision 2.29 by greg, Thu Mar 3 00:01:48 2022 UTC

# Line 27 | Line 27 | int    report = REP_WARN;      /* reporting level */
27  
28   int     ign_header = 0;         /* ignore header differences? */
29  
30 + int     escape_newlines = 0;    /* allow backslash to skip newlines */
31 +
32   double  rel_min = 1e-5;         /* positive for relative comparisons */
33  
34   double  rms_lim = 0.01;         /* RMS difference limit */
# Line 132 | Line 134 | read_line(LINEBUF *bp, FILE *fp)
134          }
135          while (fgets(bp->str + bp->len, bp->siz - bp->len, fp)) {
136                  bp->len += strlen(bp->str + bp->len);
137 <                if (bp->str[bp->len-1] == '\n')
137 >                if (bp->str[bp->len-1] == '\n') {
138 >                        if (bp->len > 1 && bp->str[bp->len-2] == '\r') {
139 >                                bp->str[--bp->len] = '\0';
140 >                                bp->str[bp->len-1] = '\n';
141 >                        }
142 >                        if (escape_newlines && bp->len > 1 &&
143 >                                        bp->str[bp->len-2] == '\\') {
144 >                                bp->str[--bp->len] = '\0';
145 >                                bp->str[bp->len-1] = ' ';
146 >                                continue;
147 >                        }
148                          break;          /* found EOL */
149 +                }
150                  if (bp->len < bp->siz - 4)
151                          continue;       /* at EOF? */
152                  if (bp->siz >= MAXBUF) {
# Line 197 | Line 210 | real_check(double r1, double r2)
210  
211          if (rel_min > 0) {      /* doing relative differences? */
212                  double  av2 = .25*(r1*r1 + 2.*fabs(r1*r2) + r2*r2);
213 <                if (av2 > rel_min*rel_min)
214 <                        diff2 /= av2;
213 >                if (av2 < rel_min*rel_min)
214 >                        av2 = rel_min*rel_min;
215 >                diff2 /= av2;
216          }
217          if (max_lim >= 0 && diff2 > max_lim*max_lim) {
218                  if (report != REP_QUIET)
# Line 372 | Line 386 | setheadvar(char *val, void *p)
386                  tep->key = strcpy(malloc(kln+1), key);
387          if (tep->data) {        /* check for special cases */
388                  if (!strcmp(key, "EXPOSURE")) {
389 <                        sprintf(newval, "%f", atof(tep->data)*atof(val));
389 >                        sprintf(newval, "%.6e", atof(tep->data)*atof(val));
390                          vln = strlen(val = newval);
391                  }
392                  free(tep->data);
# Line 568 | Line 582 | compare_text()
582          if (report >= REP_VERBOSE) {
583                  fputs(progname, stdout);
584                  fputs(": comparing inputs as ASCII text", stdout);
585 +                if (escape_newlines)
586 +                        fputs(", allowing escaped newlines", stdout);
587                  if (comment_c) {
588                          fputs(", ignoring comments starting with '", stdout);
589                          fputc(comment_c, stdout);
# Line 915 | Line 931 | main(int argc, char *argv[])
931                  switch (argv[a][1]) {
932                  case 'h':                       /* ignore header info. */
933                          ign_header = !ign_header;
934 +                        continue;
935 +                case 'n':                       /* allow newline escapes */
936 +                        escape_newlines = !escape_newlines;
937                          continue;
938                  case 'c':                       /* ignore comments */
939                          comment_c = argv[a][2];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines