| 40 |
|
"ascii", |
| 41 |
|
COLRFMT, |
| 42 |
|
CIEFMT, |
| 43 |
< |
"BINARY_float", |
| 44 |
< |
"BINARY_double", |
| 43 |
> |
"float", |
| 44 |
> |
"double", |
| 45 |
|
"BSDF_RBFmesh", |
| 46 |
|
"Radiance_octree", |
| 47 |
|
"Radiance_tmesh", |
| 74 |
|
const char stdin_name[] = "<stdin>"; |
| 75 |
|
const char *f1name=NULL, *f2name=NULL; |
| 76 |
|
FILE *f1in=NULL, *f2in=NULL; |
| 77 |
+ |
|
| 78 |
|
/* running real differences */ |
| 79 |
|
double diff2sum = 0; |
| 80 |
|
int nsum = 0; |
| 85 |
|
{ |
| 86 |
|
fputs("Usage: ", stderr); |
| 87 |
|
fputs(progname, stderr); |
| 88 |
< |
fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] file1 file2\n", |
| 88 |
> |
fputs(" [-h][-s|-w|-v][-rel min_test][-rms epsilon][-max epsilon] reference test\n", |
| 89 |
|
stderr); |
| 90 |
|
exit(1); |
| 91 |
|
} |
| 117 |
|
} |
| 118 |
|
if (max_lim >= 0 && diff2 > max_lim*max_lim) { |
| 119 |
|
if (report != REP_QUIET) |
| 120 |
< |
fprintf(stderr, |
| 120 |
> |
printf( |
| 121 |
|
"%s: %sdifference between %.8g and %.8g exceeds epsilon\n", |
| 122 |
|
progname, |
| 123 |
|
(rel_min > 0) ? "relative " : "", |
| 207 |
|
int kln, vln; |
| 208 |
|
int n; |
| 209 |
|
|
| 210 |
+ |
adv_linecnt(htp); /* side-effect is to count lines */ |
| 211 |
|
if (!isalpha(*val)) /* key must start line */ |
| 212 |
|
return(0); |
| 213 |
|
key = val++; |
| 232 |
|
if (!strcmp(key, hdr_ignkey[n])) |
| 233 |
|
return(0); |
| 234 |
|
if (!(tep = lu_find(htp, key))) |
| 235 |
< |
return(-1); |
| 235 |
> |
return(-1); /* memory allocation error */ |
| 236 |
|
if (!tep->key) |
| 237 |
|
tep->key = strcpy(malloc(kln+1), key); |
| 238 |
|
if (tep->data) |
| 239 |
|
free(tep->data); |
| 240 |
|
tep->data = strcpy(malloc(vln+1), val); |
| 239 |
– |
adv_linecnt(htp); |
| 241 |
|
return(1); |
| 242 |
|
} |
| 243 |
|
|
| 248 |
|
const LUENT *ep2 = lu_find((LUTAB *)p2, ep1->key); |
| 249 |
|
if (!ep2 || !ep2->data) { |
| 250 |
|
if (report != REP_QUIET) |
| 251 |
< |
fprintf(stderr, "%s: Variable '%s' missing in '%s'\n", |
| 251 |
> |
printf("%s: Variable '%s' missing in '%s'\n", |
| 252 |
|
progname, ep1->key, f2name); |
| 253 |
|
return(-1); |
| 254 |
|
} |
| 255 |
|
if (!equiv_string((char *)ep1->data, (char *)ep2->data)) { |
| 256 |
< |
if (report != REP_QUIET) |
| 257 |
< |
fprintf(stderr, "%s: Header variables '%s' have different values\n", |
| 256 |
> |
if (report != REP_QUIET) { |
| 257 |
> |
printf("%s: Header variable '%s' has different values\n", |
| 258 |
|
progname, ep1->key); |
| 259 |
+ |
if (report >= REP_VERBOSE) { |
| 260 |
+ |
printf("%s: %s=%s\n", f1name, |
| 261 |
+ |
ep1->key, (char *)ep1->data); |
| 262 |
+ |
printf("%s: %s=%s\n", f2name, |
| 263 |
+ |
ep2->key, (char *)ep2->data); |
| 264 |
+ |
} |
| 265 |
+ |
} |
| 266 |
|
return(-1); |
| 267 |
|
} |
| 268 |
|
return(1); /* good match */ |
| 275 |
|
int ne = lu_doall(hp1, match_val, hp2); |
| 276 |
|
if (ne < 0) |
| 277 |
|
return(0); /* something didn't match! */ |
| 278 |
< |
ne = lu_doall(hp2, NULL, NULL) - ne; |
| 279 |
< |
if (ne) { |
| 280 |
< |
if (report != REP_QUIET) |
| 273 |
< |
fprintf(stderr, "%s: '%s' has %d extra header variable(s)\n", |
| 278 |
> |
/* non-fatal if second header has extra */ |
| 279 |
> |
if (report >= REP_WARN && (ne = lu_doall(hp2, NULL, NULL) - ne)) |
| 280 |
> |
printf("%s: '%s' has %d extra header setting(s)\n", |
| 281 |
|
progname, f2name, ne); |
| 275 |
– |
return(0); |
| 276 |
– |
} |
| 282 |
|
return(1); /* good match */ |
| 283 |
|
} |
| 284 |
|
|
| 322 |
|
char sbuf[32]; |
| 323 |
|
if (!fgets(sbuf, sizeof(sbuf), fin)) |
| 324 |
|
goto badeof; |
| 325 |
+ |
adv_linecnt(htp); /* for #?ID string */ |
| 326 |
|
if (report >= REP_WARN && strncmp(sbuf, "RADIANCE", 8)) { |
| 327 |
< |
fputs(name, stderr); |
| 328 |
< |
fputs(": warning - unexpected header ID: ", stderr); |
| 329 |
< |
fputs(sbuf, stderr); |
| 327 |
> |
fputs(name, stdout); |
| 328 |
> |
fputs(": warning - unexpected header ID: ", stdout); |
| 329 |
> |
fputs(sbuf, stdout); |
| 330 |
|
} |
| 325 |
– |
adv_linecnt(htp); /* for #?ID string */ |
| 331 |
|
if (getheader(fin, setheadvar, htp) < 0) { |
| 332 |
|
fputs(name, stderr); |
| 333 |
|
fputs(": Unknown error reading header\n", stderr); |
| 348 |
|
return(TYP_TEXT); |
| 349 |
|
badeof: |
| 350 |
|
if (report != REP_QUIET) { |
| 351 |
< |
fputs(name, stderr); |
| 352 |
< |
fputs(": Unexpected end-of-file\n", stderr); |
| 351 |
> |
fputs(name, stdout); |
| 352 |
> |
fputs(": Unexpected end-of-file\n", stdout); |
| 353 |
|
} |
| 354 |
|
return(-1); |
| 355 |
|
} |
| 362 |
|
return(1); |
| 363 |
|
if (diff2sum/(double)nsum > rms_lim*rms_lim) { |
| 364 |
|
if (report != REP_QUIET) |
| 365 |
< |
fprintf(stderr, |
| 365 |
> |
printf( |
| 366 |
|
"%s: %sRMS difference between '%s' and '%s' of %.5g exceeds limit\n", |
| 367 |
|
progname, |
| 368 |
|
(rel_min > 0) ? "relative " : "", |
| 371 |
|
return(0); |
| 372 |
|
} |
| 373 |
|
if (report >= REP_VERBOSE) |
| 374 |
< |
fprintf(stderr, |
| 370 |
< |
"%s: %sRMS difference of reals in '%s' and '%s' is %.5g\n", |
| 374 |
> |
printf("%s: %sRMS difference of reals in '%s' and '%s' is %.5g\n", |
| 375 |
|
progname, (rel_min > 0) ? "relative " : "", |
| 376 |
|
f1name, f2name, sqrt(diff2sum/(double)nsum)); |
| 377 |
|
return(1); |
| 382 |
|
compare_binary() |
| 383 |
|
{ |
| 384 |
|
if (report >= REP_VERBOSE) { |
| 385 |
< |
fputs(progname, stderr); |
| 386 |
< |
fputs(": comparing inputs as binary\n", stderr); |
| 385 |
> |
fputs(progname, stdout); |
| 386 |
> |
fputs(": comparing inputs as binary\n", stdout); |
| 387 |
|
} |
| 388 |
|
for ( ; ; ) { /* exact byte matching */ |
| 389 |
|
int c1 = getc(f1in); |
| 392 |
|
if (c2 == EOF) |
| 393 |
|
return(1); /* success! */ |
| 394 |
|
if (report != REP_QUIET) { |
| 395 |
< |
fputs(f1name, stderr); |
| 396 |
< |
fputs(": Unexpected end-of-file\n", stderr); |
| 395 |
> |
fputs(f1name, stdout); |
| 396 |
> |
fputs(": Unexpected end-of-file\n", stdout); |
| 397 |
|
} |
| 398 |
|
return(0); |
| 399 |
|
} |
| 400 |
|
if (c2 == EOF) { |
| 401 |
|
if (report != REP_QUIET) { |
| 402 |
< |
fputs(f2name, stderr); |
| 403 |
< |
fputs(": Unexpected end-of-file\n", stderr); |
| 402 |
> |
fputs(f2name, stdout); |
| 403 |
> |
fputs(": Unexpected end-of-file\n", stdout); |
| 404 |
|
} |
| 405 |
|
return(0); |
| 406 |
|
} |
| 409 |
|
} |
| 410 |
|
if (report == REP_QUIET) |
| 411 |
|
return(0); |
| 412 |
< |
fprintf(stderr, "%s: binary files '%s' and '%s' differ at offset %ld|%ld\n", |
| 412 |
> |
printf("%s: binary files '%s' and '%s' differ at offset %ld|%ld\n", |
| 413 |
|
progname, f1name, f2name, ftell(f1in), ftell(f2in)); |
| 414 |
|
return(0); |
| 415 |
|
} |
| 421 |
|
char l1buf[4096], l2buf[4096]; |
| 422 |
|
|
| 423 |
|
if (report >= REP_VERBOSE) { |
| 424 |
< |
fputs(progname, stderr); |
| 425 |
< |
fputs(": comparing inputs as ASCII text\n", stderr); |
| 424 |
> |
fputs(progname, stdout); |
| 425 |
> |
fputs(": comparing inputs as ASCII text\n", stdout); |
| 426 |
|
} |
| 427 |
|
/* compare a line at a time */ |
| 428 |
|
while (fgets(l1buf, sizeof(l1buf), f1in)) { |
| 436 |
|
} |
| 437 |
|
if (feof(f2in)) { |
| 438 |
|
if (report != REP_QUIET) { |
| 439 |
< |
fputs(f2name, stderr); |
| 440 |
< |
fputs(": Unexpected end-of-file\n", stderr); |
| 439 |
> |
fputs(f2name, stdout); |
| 440 |
> |
fputs(": Unexpected end-of-file\n", stdout); |
| 441 |
|
} |
| 442 |
|
return(0); |
| 443 |
|
} |
| 444 |
|
/* compare non-empty lines */ |
| 445 |
|
if (!equiv_string(l1buf, l2buf)) { |
| 446 |
|
if (report != REP_QUIET) { |
| 447 |
< |
fprintf(stderr, "%s: inputs '%s' and '%s' differ at line %d|%d\n", |
| 447 |
> |
printf("%s: inputs '%s' and '%s' differ at line %d|%d\n", |
| 448 |
|
progname, f1name, f2name, |
| 449 |
|
lin1cnt, lin2cnt); |
| 450 |
|
if (report >= REP_VERBOSE) { |
| 451 |
< |
fputs("------------- Mismatch -------------\n", stderr); |
| 452 |
< |
fprintf(stderr, "%s(%d):\t%s", f1name, |
| 451 |
> |
fputs("------------- Mismatch -------------\n", stdout); |
| 452 |
> |
printf("%s(%d):\t%s", f1name, |
| 453 |
|
lin1cnt, l1buf); |
| 454 |
< |
fprintf(stderr, "%s(%d):\t%s", f2name, |
| 454 |
> |
printf("%s(%d):\t%s", f2name, |
| 455 |
|
lin2cnt, l2buf); |
| 456 |
|
} |
| 457 |
|
} |
| 463 |
|
if (!*sskip2(l2buf,0)) |
| 464 |
|
continue; |
| 465 |
|
if (report != REP_QUIET) { |
| 466 |
< |
fputs(f1name, stderr); |
| 467 |
< |
fputs(": Unexpected end-of-file\n", stderr); |
| 466 |
> |
fputs(f1name, stdout); |
| 467 |
> |
fputs(": Unexpected end-of-file\n", stdout); |
| 468 |
|
} |
| 469 |
|
return(0); |
| 470 |
|
} |
| 483 |
|
fgetsresolu(&rs2, f2in); |
| 484 |
|
if (rs1.rt != rs2.rt) { |
| 485 |
|
if (report != REP_QUIET) |
| 486 |
< |
fprintf(stderr, |
| 486 |
> |
printf( |
| 487 |
|
"%s: Images '%s' and '%s' have different pixel ordering\n", |
| 488 |
|
progname, f1name, f2name); |
| 489 |
|
return(0); |
| 490 |
|
} |
| 491 |
|
if ((rs1.xr != rs2.xr) | (rs1.yr != rs2.yr)) { |
| 492 |
|
if (report != REP_QUIET) |
| 493 |
< |
fprintf(stderr, |
| 493 |
> |
printf( |
| 494 |
|
"%s: Images '%s' and '%s' are different sizes\n", |
| 495 |
|
progname, f1name, f2name); |
| 496 |
|
return(0); |
| 505 |
|
if ((freadscan(scan1, scanlen(&rs1), f1in) < 0) | |
| 506 |
|
(freadscan(scan2, scanlen(&rs2), f2in) < 0)) { |
| 507 |
|
if (report != REP_QUIET) |
| 508 |
< |
fprintf(stderr, "%s: Unexpected end-of-file\n", |
| 508 |
> |
printf("%s: Unexpected end-of-file\n", |
| 509 |
|
progname); |
| 510 |
|
free(scan1); |
| 511 |
|
free(scan2); |
| 520 |
|
colval(scan2[x],BLU))) |
| 521 |
|
continue; |
| 522 |
|
if (report != REP_QUIET) { |
| 523 |
< |
fprintf(stderr, |
| 523 |
> |
printf( |
| 524 |
|
"%s: pixels at scanline %d offset %d differ\n", |
| 525 |
|
progname, y, x); |
| 526 |
|
if (report >= REP_VERBOSE) { |
| 527 |
< |
fprintf(stderr, "%s: (R,G,B)=(%g,%g,%g)\n", |
| 527 |
> |
printf("%s: (R,G,B)=(%g,%g,%g)\n", |
| 528 |
|
f1name, colval(scan1[x],RED), |
| 529 |
|
colval(scan1[x],GRN), |
| 530 |
|
colval(scan1[x],BLU)); |
| 531 |
< |
fprintf(stderr, "%s: (R,G,B)=(%g,%g,%g)\n", |
| 531 |
> |
printf("%s: (R,G,B)=(%g,%g,%g)\n", |
| 532 |
|
f2name, colval(scan2[x],RED), |
| 533 |
|
colval(scan2[x],GRN), |
| 534 |
|
colval(scan2[x],BLU)); |
| 562 |
|
if (real_check(f1, f2)) |
| 563 |
|
continue; |
| 564 |
|
if (report != REP_QUIET) |
| 565 |
< |
fprintf(stderr, "%s: %ld%s float values differ\n", |
| 565 |
> |
printf("%s: %ld%s float values differ\n", |
| 566 |
|
progname, nread, nsuffix[nread%10]); |
| 567 |
|
return(0); |
| 568 |
|
} |
| 570 |
|
return(good_RMS()); /* final check of RMS */ |
| 571 |
|
badeof: |
| 572 |
|
if (report != REP_QUIET) |
| 573 |
< |
fprintf(stderr, "%s: Unexpected end-of-file\n", progname); |
| 573 |
> |
printf("%s: Unexpected end-of-file\n", progname); |
| 574 |
|
return(0); |
| 575 |
|
} |
| 576 |
|
|
| 588 |
|
if (real_check(f1, f2)) |
| 589 |
|
continue; |
| 590 |
|
if (report != REP_QUIET) |
| 591 |
< |
fprintf(stderr, "%s: %ld%s float values differ\n", |
| 591 |
> |
printf("%s: %ld%s float values differ\n", |
| 592 |
|
progname, nread, nsuffix[nread%10]); |
| 593 |
|
return(0); |
| 594 |
|
} |
| 596 |
|
return(good_RMS()); /* final check of RMS */ |
| 597 |
|
badeof: |
| 598 |
|
if (report != REP_QUIET) |
| 599 |
< |
fprintf(stderr, "%s: Unexpected end-of-file\n", progname); |
| 599 |
> |
printf("%s: Unexpected end-of-file\n", progname); |
| 600 |
|
return(0); |
| 601 |
|
} |
| 602 |
|
|
| 650 |
|
|
| 651 |
|
if (!strcmp(f1name, f2name)) { /* inputs are same? */ |
| 652 |
|
if (report >= REP_WARN) |
| 653 |
< |
fprintf(stderr, "%s: warning - identical inputs given\n", |
| 653 |
> |
printf("%s: warning - identical inputs given\n", |
| 654 |
|
progname); |
| 655 |
|
return(0); |
| 656 |
|
} |
| 674 |
|
return(1); |
| 675 |
|
if (typ1 != typ2) { |
| 676 |
|
if (report != REP_QUIET) |
| 677 |
< |
fprintf(stderr, "%s: '%s' is %s and '%s' is %s\n", |
| 677 |
> |
printf("%s: '%s' is %s and '%s' is %s\n", |
| 678 |
|
progname, f1name, file_type[typ1], |
| 679 |
|
f2name, file_type[typ2]); |
| 680 |
|
return(1); |
| 685 |
|
lu_done(&hdr1); lu_done(&hdr2); |
| 686 |
|
if (!ign_header & (report >= REP_WARN)) { |
| 687 |
|
if (typ1 == TYP_UNKNOWN) |
| 688 |
< |
fprintf(stderr, "%s: warning - unrecognized format, comparing as binary\n", |
| 688 |
> |
printf("%s: warning - unrecognized format, comparing as binary\n", |
| 689 |
|
progname); |
| 690 |
|
if (lin1cnt != lin2cnt) |
| 691 |
< |
fprintf(stderr, "%s: warning - headers are different lengths\n", |
| 691 |
> |
printf("%s: warning - headers are different lengths\n", |
| 692 |
|
progname); |
| 693 |
|
} |
| 694 |
|
if (report >= REP_VERBOSE) |
| 695 |
< |
fprintf(stderr, "%s: input file type is %s\n", |
| 695 |
> |
printf("%s: input file type is %s\n", |
| 696 |
|
progname, file_type[typ1]); |
| 697 |
|
|
| 698 |
|
switch (typ1) { /* compare based on type */ |