annotate TOOLS/compare.c @ 34333:e8e4e6f9b7ac

Change prefix for internal events from ev to iv. This is in order to distinguish them from the external ones.
author ib
date Fri, 09 Dec 2011 13:34:38 +0000
parents 32725ca88fed
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25802
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
1 /*
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
2 * Simple file compare program, it finds the number of rounding errors
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
3 * and dies if there is too large an error ( ABS(a-b)>1 ).
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
4 *
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
5 * copyright (c) 2001 Michael Niedermayer
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
6 *
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
10 * (at your option) any later version.
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
11 *
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
15 * GNU General Public License for more details.
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
16 *
27503
c63874a24179 Fix incorrect FSF address in license header.
diego
parents: 25802
diff changeset
17 * You should have received a copy of the GNU General Public License along
c63874a24179 Fix incorrect FSF address in license header.
diego
parents: 25802
diff changeset
18 * with this program; if not, write to the Free Software Foundation, Inc.,
c63874a24179 Fix incorrect FSF address in license header.
diego
parents: 25802
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25802
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
20 */
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
21
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
22 #include <stdio.h>
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
23 #include <stdlib.h>
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
24
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
25 // FIXME: No checks but it is just for debugging so who cares ;)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
26
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
27 int main(int argc, char **argv)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
28 {
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
29 FILE *f0, *f1;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
30 int dif=0;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
31
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
32 if(argc!=3)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
33 {
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
34 printf("compare <file1> <file2>\n");
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
35 exit(2);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
36 }
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
37
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
38 f0= fopen(argv[1], "rb");
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
39 f1= fopen(argv[2], "rb");
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
40
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
41 for(;;)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
42 {
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
43 short c0;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
44 short c1;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
45 int d;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
46
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
47 int e0= fread(&c0, 2, 1, f0);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
48 int e1= fread(&c1, 2, 1, f1);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
49
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
50 d=c0-c1;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
51 if(e0==0 && e1==0) break;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
52 if(e0==0 || e1==0)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
53 {
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
54 printf("FATAL error, files have different size!\n");
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
55 exit(1);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
56 }
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
57
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
58 if(d<0) d=-d; // ABS
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
59 if(d>1)
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
60 {
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
61 printf("FATAL error, too large a difference found (%d)!\n", d);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
62 exit(1);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
63 }
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
64
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
65 if(d) dif++;
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
66 }
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
67
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
68 fclose(f0);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
69 fclose(f1);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
70
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
71 printf("%d (+/-1)differences found\n", dif);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
72 exit(0);
2118c88fe0e1 Move compare.c to TOOLS, add it to the Makefile and document it.
diego
parents:
diff changeset
73 }