Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / liba52 / compare.c
blobd5bade9eb7e6e85e30d40b70c710f20f14a8daad
1 // File written by Michael Niedermayer and it is under GPL.
2 // Simple file compare program, it finds the number of rounding errors
3 // and dies if there is too large an error ( ABS(a-b)>1 ).
5 #include <stdio.h>
6 #include <stdlib.h>
8 // FIXME: No checks but it is just for debugging so who cares ;)
10 int main(int argc, char **argv)
12 FILE *f0, *f1;
13 int dif=0;
15 if(argc!=3)
17 printf("compare <file1> <file2>\n");
18 exit(2);
21 f0= fopen(argv[1], "rb");
22 f1= fopen(argv[2], "rb");
24 for(;;)
26 short c0;
27 short c1;
28 int d;
30 int e0= fread(&c0, 2, 1, f0);
31 int e1= fread(&c1, 2, 1, f1);
33 d=c0-c1;
34 if(e0==0 && e1==0) break;
35 if(e0==0 || e1==0)
37 printf("FATAL error, files have different size!\n");
38 exit(1);
41 if(d<0) d=-d; // ABS
42 if(d>1)
44 printf("FATAL error, too large a difference found (%d)!\n", d);
45 exit(1);
48 if(d) dif++;
51 fclose(f0);
52 fclose(f1);
54 printf("%d (+/-1)differences found\n", dif);
55 exit(0);