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 |
|
}; |
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 |
|
} |
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, |
197 |
|
|
198 |
|
if (rel_min > 0) { /* doing relative differences? */ |
199 |
|
double av2 = .25*(r1*r1 + 2.*fabs(r1*r2) + r2*r2); |
200 |
< |
if (av2 > rel_min*rel_min) |
201 |
< |
diff2 /= av2; |
200 |
> |
if (av2 < rel_min*rel_min) |
201 |
> |
av2 = rel_min*rel_min; |
202 |
> |
diff2 /= av2; |
203 |
|
} |
204 |
|
if (max_lim >= 0 && diff2 > max_lim*max_lim) { |
205 |
|
if (report != REP_QUIET) |
328 |
|
static int |
329 |
|
setheadvar(char *val, void *p) |
330 |
|
{ |
331 |
+ |
char newval[128]; |
332 |
|
LUTAB *htp = (LUTAB *)p; |
333 |
|
LUENT *tep; |
334 |
|
char *key; |
371 |
|
return(-1); /* memory allocation error */ |
372 |
|
if (!tep->key) |
373 |
|
tep->key = strcpy(malloc(kln+1), key); |
374 |
< |
if (tep->data) |
374 |
> |
if (tep->data) { /* check for special cases */ |
375 |
> |
if (!strcmp(key, "EXPOSURE")) { |
376 |
> |
sprintf(newval, "%f", atof(tep->data)*atof(val)); |
377 |
> |
vln = strlen(val = newval); |
378 |
> |
} |
379 |
|
free(tep->data); |
380 |
+ |
} |
381 |
|
tep->data = strcpy(malloc(vln+1), val); |
382 |
|
return(1); |
383 |
|
} |
486 |
|
} |
487 |
|
if (c) |
488 |
|
return(TYP_BINARY); |
472 |
– |
SET_FILE_TEXT(fin); /* originally set to binary */ |
489 |
|
return(TYP_TEXT); |
490 |
|
badeof: |
491 |
|
if (report != REP_QUIET) { |
568 |
|
|
569 |
|
if (report >= REP_VERBOSE) { |
570 |
|
fputs(progname, stdout); |
571 |
< |
fputs(": comparing inputs as ASCII text\n", stdout); |
571 |
> |
fputs(": comparing inputs as ASCII text", stdout); |
572 |
> |
if (comment_c) { |
573 |
> |
fputs(", ignoring comments starting with '", stdout); |
574 |
> |
fputc(comment_c, stdout); |
575 |
> |
fputc('\'', stdout); |
576 |
> |
} |
577 |
> |
fputc('\n', stdout); |
578 |
|
} |
579 |
+ |
SET_FILE_TEXT(f1in); /* originally set to binary */ |
580 |
+ |
SET_FILE_TEXT(f2in); |
581 |
|
init_line(&l1buf); init_line(&l2buf); /* compare a line at a time */ |
582 |
|
while (read_line(&l1buf, f1in)) { |
583 |
|
lin1cnt++; |
720 |
|
static char depthvar[] = DEPTHSTR; |
721 |
|
const char *drval; |
722 |
|
|
723 |
< |
depthvar[LDEPTHSTR] = '\0'; |
723 |
> |
depthvar[LDEPTHSTR-1] = '\0'; |
724 |
|
drval = (const char *)lu_find(htp, depthvar)->data; |
725 |
|
if (!drval) |
726 |
|
return(0); |
916 |
|
switch (argv[a][1]) { |
917 |
|
case 'h': /* ignore header info. */ |
918 |
|
ign_header = !ign_header; |
919 |
+ |
continue; |
920 |
+ |
case 'c': /* ignore comments */ |
921 |
+ |
comment_c = argv[a][2]; |
922 |
|
continue; |
923 |
|
case 's': /* silent operation */ |
924 |
|
report = REP_QUIET; |