| 33 |
|
|
| 34 |
|
int lin1cnt=0, lin2cnt=0; /* file line position */ |
| 35 |
|
|
| 36 |
+ |
const char nsuffix[10][3] = { /* 1st, 2nd, 3rd, etc. */ |
| 37 |
+ |
"th","st","nd","rd","th","th","th","th","th","th" |
| 38 |
+ |
}; |
| 39 |
+ |
#define num_sfx(n) nsuffix[(n)%10] |
| 40 |
+ |
|
| 41 |
|
/* file types */ |
| 42 |
|
const char *file_type[] = { |
| 43 |
|
"Unrecognized", |
| 53 |
|
"BINARY_unknown", |
| 54 |
|
NULL /* terminator */ |
| 55 |
|
}; |
| 56 |
< |
|
| 56 |
> |
/* keep consistent with above */ |
| 57 |
|
enum {TYP_UNKNOWN, TYP_TEXT, TYP_ASCII, TYP_RGBE, TYP_XYZE, TYP_FLOAT, |
| 58 |
|
TYP_DOUBLE, TYP_RBFMESH, TYP_OCTREE, TYP_TMESH, TYP_BINARY}; |
| 59 |
|
|
| 123 |
|
if (max_lim >= 0 && diff2 > max_lim*max_lim) { |
| 124 |
|
if (report != REP_QUIET) |
| 125 |
|
printf( |
| 126 |
< |
"%s: %sdifference between %.8g and %.8g exceeds epsilon\n", |
| 126 |
> |
"%s: %sdifference between %.8g and %.8g exceeds epsilon of %.8g\n", |
| 127 |
|
progname, |
| 128 |
|
(rel_min > 0) ? "relative " : "", |
| 129 |
< |
r1, r2); |
| 129 |
> |
r1, r2, max_lim); |
| 130 |
|
return(0); |
| 131 |
|
} |
| 132 |
|
diff2sum += diff2; |
| 228 |
|
val++; |
| 229 |
|
if (!*val) /* nothing set? */ |
| 230 |
|
return(0); |
| 226 |
– |
vln = strlen(val); /* eliminate space and newline at end */ |
| 227 |
– |
while (--vln > 0 && isspace(val[vln])) |
| 228 |
– |
; |
| 229 |
– |
val[++vln] = '\0'; |
| 231 |
|
/* check if key to ignore */ |
| 232 |
|
for (n = 0; hdr_ignkey[n]; n++) |
| 233 |
|
if (!strcmp(key, hdr_ignkey[n])) |
| 234 |
|
return(0); |
| 235 |
+ |
vln = strlen(val); /* eliminate space and newline at end */ |
| 236 |
+ |
while (isspace(val[--vln])) |
| 237 |
+ |
; |
| 238 |
+ |
val[++vln] = '\0'; |
| 239 |
|
if (!(tep = lu_find(htp, key))) |
| 240 |
|
return(-1); /* memory allocation error */ |
| 241 |
|
if (!tep->key) |
| 253 |
|
const LUENT *ep2 = lu_find((LUTAB *)p2, ep1->key); |
| 254 |
|
if (!ep2 || !ep2->data) { |
| 255 |
|
if (report != REP_QUIET) |
| 256 |
< |
printf("%s: Variable '%s' missing in '%s'\n", |
| 256 |
> |
printf("%s: variable '%s' missing in '%s'\n", |
| 257 |
|
progname, ep1->key, f2name); |
| 258 |
|
return(-1); |
| 259 |
|
} |
| 260 |
|
if (!equiv_string((char *)ep1->data, (char *)ep2->data)) { |
| 261 |
|
if (report != REP_QUIET) { |
| 262 |
< |
printf("%s: Header variable '%s' has different values\n", |
| 262 |
> |
printf("%s: header variable '%s' has different values\n", |
| 263 |
|
progname, ep1->key); |
| 264 |
|
if (report >= REP_VERBOSE) { |
| 265 |
|
printf("%s: %s=%s\n", f1name, |
| 282 |
|
return(0); /* something didn't match! */ |
| 283 |
|
/* non-fatal if second header has extra */ |
| 284 |
|
if (report >= REP_WARN && (ne = lu_doall(hp2, NULL, NULL) - ne)) |
| 285 |
< |
printf("%s: '%s' has %d extra header setting(s)\n", |
| 285 |
> |
printf("%s: warning - '%s' has %d extra header setting(s)\n", |
| 286 |
|
progname, f2name, ne); |
| 287 |
|
return(1); /* good match */ |
| 288 |
|
} |
| 295 |
|
int c = 0; |
| 296 |
|
|
| 297 |
|
while ((c = getc(fin)) != EOF) { |
| 298 |
+ |
++n; |
| 299 |
|
if (!c | (c > 127)) |
| 300 |
|
break; /* non-ascii character */ |
| 301 |
< |
if (++n >= 10240) |
| 301 |
> |
if (n >= 10240) |
| 302 |
|
break; /* enough to be confident */ |
| 303 |
|
} |
| 304 |
|
if (!n) |
| 336 |
|
} |
| 337 |
|
if (getheader(fin, setheadvar, htp) < 0) { |
| 338 |
|
fputs(name, stderr); |
| 339 |
< |
fputs(": Unknown error reading header\n", stderr); |
| 339 |
> |
fputs(": unknown error reading header\n", stderr); |
| 340 |
|
return(-1); |
| 341 |
|
} |
| 342 |
|
adv_linecnt(htp); /* for trailing emtpy line */ |
| 355 |
|
badeof: |
| 356 |
|
if (report != REP_QUIET) { |
| 357 |
|
fputs(name, stdout); |
| 358 |
< |
fputs(": Unexpected end-of-file\n", stdout); |
| 358 |
> |
fputs(": unexpected end-of-file\n", stdout); |
| 359 |
|
} |
| 360 |
|
return(-1); |
| 361 |
|
} |
| 369 |
|
if (diff2sum/(double)nsum > rms_lim*rms_lim) { |
| 370 |
|
if (report != REP_QUIET) |
| 371 |
|
printf( |
| 372 |
< |
"%s: %sRMS difference between '%s' and '%s' of %.5g exceeds limit\n", |
| 372 |
> |
"%s: %sRMS difference between '%s' and '%s' of %.5g exceeds limit of %.5g\n", |
| 373 |
|
progname, |
| 374 |
|
(rel_min > 0) ? "relative " : "", |
| 375 |
|
f1name, f2name, |
| 376 |
< |
sqrt(diff2sum/(double)nsum)); |
| 376 |
> |
sqrt(diff2sum/(double)nsum), rms_lim); |
| 377 |
|
return(0); |
| 378 |
|
} |
| 379 |
|
if (report >= REP_VERBOSE) |
| 387 |
|
static int |
| 388 |
|
compare_binary() |
| 389 |
|
{ |
| 390 |
+ |
int c1=0, c2=0; |
| 391 |
+ |
|
| 392 |
|
if (report >= REP_VERBOSE) { |
| 393 |
|
fputs(progname, stdout); |
| 394 |
|
fputs(": comparing inputs as binary\n", stdout); |
| 395 |
|
} |
| 396 |
|
for ( ; ; ) { /* exact byte matching */ |
| 397 |
< |
int c1 = getc(f1in); |
| 398 |
< |
int c2 = getc(f2in); |
| 397 |
> |
c1 = getc(f1in); |
| 398 |
> |
c2 = getc(f2in); |
| 399 |
|
if (c1 == EOF) { |
| 400 |
|
if (c2 == EOF) |
| 401 |
|
return(1); /* success! */ |
| 402 |
|
if (report != REP_QUIET) { |
| 403 |
|
fputs(f1name, stdout); |
| 404 |
< |
fputs(": Unexpected end-of-file\n", stdout); |
| 404 |
> |
fputs(": unexpected end-of-file\n", stdout); |
| 405 |
|
} |
| 406 |
|
return(0); |
| 407 |
|
} |
| 408 |
|
if (c2 == EOF) { |
| 409 |
|
if (report != REP_QUIET) { |
| 410 |
|
fputs(f2name, stdout); |
| 411 |
< |
fputs(": Unexpected end-of-file\n", stdout); |
| 411 |
> |
fputs(": unexpected end-of-file\n", stdout); |
| 412 |
|
} |
| 413 |
|
return(0); |
| 414 |
|
} |
| 417 |
|
} |
| 418 |
|
if (report == REP_QUIET) |
| 419 |
|
return(0); |
| 420 |
< |
printf("%s: binary files '%s' and '%s' differ at offset %ld|%ld\n", |
| 420 |
> |
printf("%s: binary files '%s' and '%s' differ at byte offset %ld|%ld\n", |
| 421 |
|
progname, f1name, f2name, ftell(f1in), ftell(f2in)); |
| 422 |
+ |
if (report >= REP_VERBOSE) |
| 423 |
+ |
printf("%s: byte in '%s' is 0x%X, byte in '%s' is 0x%X\n", |
| 424 |
+ |
progname, f1name, c1, f2name, c2); |
| 425 |
|
return(0); |
| 426 |
|
} |
| 427 |
|
|
| 448 |
|
if (feof(f2in)) { |
| 449 |
|
if (report != REP_QUIET) { |
| 450 |
|
fputs(f2name, stdout); |
| 451 |
< |
fputs(": Unexpected end-of-file\n", stdout); |
| 451 |
> |
fputs(": unexpected end-of-file\n", stdout); |
| 452 |
|
} |
| 453 |
|
return(0); |
| 454 |
|
} |
| 460 |
|
lin1cnt, lin2cnt); |
| 461 |
|
if (report >= REP_VERBOSE) { |
| 462 |
|
fputs("------------- Mismatch -------------\n", stdout); |
| 463 |
< |
printf("%s(%d):\t%s", f1name, |
| 463 |
> |
printf("%s@%d:\t%s", f1name, |
| 464 |
|
lin1cnt, l1buf); |
| 465 |
< |
printf("%s(%d):\t%s", f2name, |
| 465 |
> |
printf("%s@%d:\t%s", f2name, |
| 466 |
|
lin2cnt, l2buf); |
| 467 |
|
} |
| 468 |
|
} |
| 475 |
|
continue; |
| 476 |
|
if (report != REP_QUIET) { |
| 477 |
|
fputs(f1name, stdout); |
| 478 |
< |
fputs(": Unexpected end-of-file\n", stdout); |
| 478 |
> |
fputs(": unexpected end-of-file\n", stdout); |
| 479 |
|
} |
| 480 |
|
return(0); |
| 481 |
|
} |
| 490 |
|
COLOR *scan1, *scan2; |
| 491 |
|
int x, y; |
| 492 |
|
|
| 493 |
+ |
if (report >= REP_VERBOSE) { |
| 494 |
+ |
fputs(progname, stdout); |
| 495 |
+ |
fputs(": comparing inputs as HDR images\n", stdout); |
| 496 |
+ |
} |
| 497 |
|
fgetsresolu(&rs1, f1in); |
| 498 |
|
fgetsresolu(&rs2, f2in); |
| 499 |
|
if (rs1.rt != rs2.rt) { |
| 520 |
|
if ((freadscan(scan1, scanlen(&rs1), f1in) < 0) | |
| 521 |
|
(freadscan(scan2, scanlen(&rs2), f2in) < 0)) { |
| 522 |
|
if (report != REP_QUIET) |
| 523 |
< |
printf("%s: Unexpected end-of-file\n", |
| 523 |
> |
printf("%s: unexpected end-of-file\n", |
| 524 |
|
progname); |
| 525 |
|
free(scan1); |
| 526 |
|
free(scan2); |
| 527 |
|
return(0); |
| 528 |
|
} |
| 529 |
< |
for (x = scanlen(&rs1); x--; ) { |
| 529 |
> |
for (x = 0; x < scanlen(&rs1); x++) { |
| 530 |
|
if (real_check(colval(scan1[x],RED), |
| 531 |
|
colval(scan2[x],RED)) & |
| 532 |
|
real_check(colval(scan1[x],GRN), |
| 559 |
|
return(good_RMS()); /* final check of RMS */ |
| 560 |
|
} |
| 561 |
|
|
| 547 |
– |
const char nsuffix[10][3] = { /* 1st, 2nd, 3rd, etc. */ |
| 548 |
– |
"th","st","nd","rd","th","th","th","th","th","th" |
| 549 |
– |
}; |
| 550 |
– |
|
| 562 |
|
/* Compare two inputs that are known to be 32-bit floating-point data */ |
| 563 |
|
static int |
| 564 |
|
compare_float() |
| 566 |
|
long nread = 0; |
| 567 |
|
float f1, f2; |
| 568 |
|
|
| 569 |
+ |
if (report >= REP_VERBOSE) { |
| 570 |
+ |
fputs(progname, stdout); |
| 571 |
+ |
fputs(": comparing inputs as 32-bit IEEE float\n", stdout); |
| 572 |
+ |
} |
| 573 |
|
while (getbinary(&f1, sizeof(f1), 1, f1in)) { |
| 574 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 575 |
|
goto badeof; |
| 578 |
|
continue; |
| 579 |
|
if (report != REP_QUIET) |
| 580 |
|
printf("%s: %ld%s float values differ\n", |
| 581 |
< |
progname, nread, nsuffix[nread%10]); |
| 581 |
> |
progname, nread, num_sfx(nread)); |
| 582 |
|
return(0); |
| 583 |
|
} |
| 584 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 585 |
|
return(good_RMS()); /* final check of RMS */ |
| 586 |
|
badeof: |
| 587 |
|
if (report != REP_QUIET) |
| 588 |
< |
printf("%s: Unexpected end-of-file\n", progname); |
| 588 |
> |
printf("%s: unexpected end-of-file\n", progname); |
| 589 |
|
return(0); |
| 590 |
|
} |
| 591 |
|
|
| 596 |
|
long nread = 0; |
| 597 |
|
double f1, f2; |
| 598 |
|
|
| 599 |
+ |
if (report >= REP_VERBOSE) { |
| 600 |
+ |
fputs(progname, stdout); |
| 601 |
+ |
fputs(": comparing inputs as 64-bit IEEE double\n", stdout); |
| 602 |
+ |
} |
| 603 |
|
while (getbinary(&f1, sizeof(f1), 1, f1in)) { |
| 604 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 605 |
|
goto badeof; |
| 607 |
|
if (real_check(f1, f2)) |
| 608 |
|
continue; |
| 609 |
|
if (report != REP_QUIET) |
| 610 |
< |
printf("%s: %ld%s float values differ\n", |
| 611 |
< |
progname, nread, nsuffix[nread%10]); |
| 610 |
> |
printf("%s: %ld%s double values differ\n", |
| 611 |
> |
progname, nread, num_sfx(nread)); |
| 612 |
|
return(0); |
| 613 |
|
} |
| 614 |
|
if (!getbinary(&f2, sizeof(f2), 1, f2in)) |
| 615 |
|
return(good_RMS()); /* final check of RMS */ |
| 616 |
|
badeof: |
| 617 |
|
if (report != REP_QUIET) |
| 618 |
< |
printf("%s: Unexpected end-of-file\n", progname); |
| 618 |
> |
printf("%s: unexpected end-of-file\n", progname); |
| 619 |
|
return(0); |
| 620 |
|
} |
| 621 |
|
|