~ubuntu-branches/ubuntu/hardy/openssl/hardy-security

« back to all changes in this revision

Viewing changes to ms/cmp.pl

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Martin
  • Date: 2004-05-24 17:02:29 UTC
  • Revision ID: james.westby@ubuntu.com-20040524170229-ixlo08bbbly0xied
Tags: upstream-0.9.7d
ImportĀ upstreamĀ versionĀ 0.9.7d

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/local/bin/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);