3510
|
1 // File written by Michael Niedermayer and its under GPL
|
|
2 // simple file compare program, it finds the number of rounding errors
|
|
3 // and dies if there is a larger error ( ABS(a-b)>1 )
|
|
4
|
|
5 #include <stdio.h>
|
|
6
|
|
7 // FIXME no checks but its just for debuging so who cares ;)
|
|
8
|
|
9 int main(int argc, char **argv)
|
|
10 {
|
|
11 FILE *f0, *f1;
|
|
12 int dif=0;
|
|
13
|
|
14 if(argc!=3)
|
|
15 {
|
|
16 printf("compare <file1> <file2>\n");
|
|
17 exit(2);
|
|
18 }
|
|
19
|
|
20 f0= fopen(argv[1], "rb");
|
|
21 f1= fopen(argv[2], "rb");
|
|
22
|
|
23 for(;;)
|
|
24 {
|
3524
|
25 short c0;
|
|
26 short c1;
|
|
27 int d;
|
|
28
|
|
29 int e0= fread(&c0, 2, 1, f0);
|
|
30 int e1= fread(&c1, 2, 1, f1);
|
|
31
|
|
32 d=c0-c1;
|
|
33 if(e0==0 && e1==0) break;
|
|
34 if(e0==0 || e1==0)
|
3510
|
35 {
|
|
36 printf("FATAL error, files have different size!\n");
|
|
37 exit(1);
|
|
38 }
|
|
39
|
|
40 if(d<0) d=-d; // ABS
|
|
41 if(d>1)
|
|
42 {
|
3524
|
43 printf("FATAL error, too large differnce found (%d)!\n", d);
|
3510
|
44 exit(1);
|
|
45 }
|
|
46
|
|
47 if(d) dif++;
|
|
48 }
|
|
49
|
|
50 fclose(f0);
|
|
51 fclose(f1);
|
|
52
|
|
53 printf("%d (+/-1)differences found\n", dif);
|
|
54 exit(0);
|
|
55 } |