set exec attribute for .pl files
[openssl.git] / ms / cmp.pl
1 #!/usr/bin/env perl
2
3 ($#ARGV == 1) || die "usage: cmp.pl <file1> <file2>\n";
4
5 open(IN0,"<$ARGV[0]") || die "unable to open $ARGV[0]\n";
6 open(IN1,"<$ARGV[1]") || die "unable to open $ARGV[1]\n";
7 binmode IN0;
8 binmode IN1;
9
10 $tot=0;
11 $ret=1;
12 for (;;)
13 {
14     $n1=sysread(IN0,$b1,4096);
15     $n2=sysread(IN1,$b2,4096);
16
17     last if ($n1 != $n2);
18     last if ($b1 ne $b2);
19     last if ($n1 < 0);
20     if ($n1 == 0)
21     {
22         $ret=0;
23         last;
24     }
25     $tot+=$n1;
26 }
27
28 close(IN0);
29 close(IN1);
30 if ($ret)
31 {
32     printf STDERR "$ARGV[0] and $ARGV[1] are different\n";
33     @a1=unpack("C*",$b1);
34     @a2=unpack("C*",$b2);
35     for ($i=0; $i<=$#a1; $i++)
36     {
37         if ($a1[$i] ne $a2[$i])
38         {
39             printf "%02X %02X <<\n",$a1[$i],$a2[$i];
40             last;
41         }
42     }
43     $nm=$tot+$n1;
44     $tot+=$i+1;
45     printf STDERR "diff at char $tot of $nm\n";
46 }
47 exit($ret);