Mercurial > mplayer.hg
comparison liba52/compare.c @ 3510:0e5829f1fb75
gcc -O? thinks a*0.0 != 0.0 so we need a better cmp
author | michael |
---|---|
date | Sun, 16 Dec 2001 00:31:44 +0000 |
parents | |
children | aed9850ca011 |
comparison
equal
deleted
inserted
replaced
3509:21c7b77b3e83 | 3510:0e5829f1fb75 |
---|---|
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 { | |
25 int c0= fgetc(f0); | |
26 int c1= fgetc(f1); | |
27 int d= c0-c1; | |
28 if(c0<0 && c1<0) break; | |
29 if(c0<0 || c1<0) | |
30 { | |
31 printf("FATAL error, files have different size!\n"); | |
32 exit(1); | |
33 } | |
34 | |
35 if(d<0) d=-d; // ABS | |
36 if(d>1) | |
37 { | |
38 printf("FATAL error, too large differnce found!\n"); | |
39 exit(1); | |
40 } | |
41 | |
42 if(d) dif++; | |
43 } | |
44 | |
45 fclose(f0); | |
46 fclose(f1); | |
47 | |
48 printf("%d (+/-1)differences found\n", dif); | |
49 exit(0); | |
50 } |