diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-19 18:05:48 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-19 18:05:48 +0000 |
commit | a6e24811207ad2179b0dabe3d7e6ec551e6686df (patch) | |
tree | 1078f32b9b52660ddbb0dc1aa5fdd25aae8f3a99 | |
parent | 8bd4afeb876fd0015bb808eb2f3de1fe709658a7 (diff) |
Use Digest::MD5 (a Perl module that should come bundled standard with Perl) to compute file digests instead of using the external program "sha1sum" (which may not be present).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49954 91177308-0d34-0410-b5e6-96231b3b80d8
-rwxr-xr-x | utils/scan-build | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/utils/scan-build b/utils/scan-build index 99262e4e1e..920ba47c0b 100755 --- a/utils/scan-build +++ b/utils/scan-build @@ -16,6 +16,7 @@ use strict; use warnings; use File::Temp qw/ :mktemp /; use FindBin qw($RealBin); +use Digest::MD5; my $Verbose = 0; # Verbose output from this script. my $Prog = "scan-build"; @@ -122,10 +123,20 @@ sub SetHtmlEnv { sub ComputeDigest { my $FName = shift; die "Cannot read $FName" if (! -r $FName); - my $Result = `sha1sum -b $FName`; - my @Output = split /\s+/,$Result; - die "Bad output from sha1sum" if (scalar(@Output) != 2); - return $Output[0]; + + # Use Digest::MD5. We don't have to be cryptographically secure. We're + # just looking for duplicate files that come from a non-maliciious source. + # We use Digest::MD5 becomes it is a standard Perl module that should + # come bundled on most systems. + + open(FILE, $FName) or die "Cannot open $FName."; + binmode FILE; + my $Result = Digest::MD5->new->addfile(*FILE)->hexdigest; + close(FILE); + + # Return the digest. + + return $Result; } ##----------------------------------------------------------------------------## |