[cfe-commits] r49954 - /cfe/trunk/utils/scan-build

Ted Kremenek kremenek at apple.com
Sat Apr 19 11:05:48 PDT 2008


Author: kremenek
Date: Sat Apr 19 13:05:48 2008
New Revision: 49954

URL: http://llvm.org/viewvc/llvm-project?rev=49954&view=rev
Log:
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).

Modified:
    cfe/trunk/utils/scan-build

Modified: cfe/trunk/utils/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/scan-build?rev=49954&r1=49953&r2=49954&view=diff

==============================================================================
--- cfe/trunk/utils/scan-build (original)
+++ cfe/trunk/utils/scan-build Sat Apr 19 13:05:48 2008
@@ -16,6 +16,7 @@
 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 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;
 }
 
 ##----------------------------------------------------------------------------##





More information about the cfe-commits mailing list