|
Packit Service |
084de1 |
#! /usr/bin/env perl
|
|
Packit Service |
084de1 |
# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
|
|
Packit Service |
084de1 |
#
|
|
Packit Service |
084de1 |
# Licensed under the OpenSSL license (the "License"). You may not use
|
|
Packit Service |
084de1 |
# this file except in compliance with the License. You can obtain a copy
|
|
Packit Service |
084de1 |
# in the file LICENSE in the source distribution or at
|
|
Packit Service |
084de1 |
# https://www.openssl.org/source/license.html
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
($#ARGV == 1) || die "usage: cmp.pl <file1> <file2>\n";
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
open(IN0,"<$ARGV[0]") || die "unable to open $ARGV[0]\n";
|
|
Packit Service |
084de1 |
open(IN1,"<$ARGV[1]") || die "unable to open $ARGV[1]\n";
|
|
Packit Service |
084de1 |
binmode IN0;
|
|
Packit Service |
084de1 |
binmode IN1;
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
$tot=0;
|
|
Packit Service |
084de1 |
$ret=1;
|
|
Packit Service |
084de1 |
for (;;)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
$n1=sysread(IN0,$b1,4096);
|
|
Packit Service |
084de1 |
$n2=sysread(IN1,$b2,4096);
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
last if ($n1 != $n2);
|
|
Packit Service |
084de1 |
last if ($b1 ne $b2);
|
|
Packit Service |
084de1 |
last if ($n1 < 0);
|
|
Packit Service |
084de1 |
if ($n1 == 0)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
$ret=0;
|
|
Packit Service |
084de1 |
last;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
$tot+=$n1;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
|
|
Packit Service |
084de1 |
close(IN0);
|
|
Packit Service |
084de1 |
close(IN1);
|
|
Packit Service |
084de1 |
if ($ret)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
printf STDERR "$ARGV[0] and $ARGV[1] are different\n";
|
|
Packit Service |
084de1 |
@a1=unpack("C*",$b1);
|
|
Packit Service |
084de1 |
@a2=unpack("C*",$b2);
|
|
Packit Service |
084de1 |
for ($i=0; $i<=$#a1; $i++)
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
if ($a1[$i] ne $a2[$i])
|
|
Packit Service |
084de1 |
{
|
|
Packit Service |
084de1 |
printf "%02X %02X <<\n",$a1[$i],$a2[$i];
|
|
Packit Service |
084de1 |
last;
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
$nm=$tot+$n1;
|
|
Packit Service |
084de1 |
$tot+=$i+1;
|
|
Packit Service |
084de1 |
printf STDERR "diff at char $tot of $nm\n";
|
|
Packit Service |
084de1 |
}
|
|
Packit Service |
084de1 |
exit($ret);
|