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 |
|
|
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) |
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 |
|
} |
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 |
|
} |
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 |
|
} |
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); |
559 |
|
return(good_RMS()); /* final check of RMS */ |
560 |
|
} |
561 |
|
|
553 |
– |
const char nsuffix[10][3] = { /* 1st, 2nd, 3rd, etc. */ |
554 |
– |
"th","st","nd","rd","th","th","th","th","th","th" |
555 |
– |
}; |
556 |
– |
|
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 |
|
|