2004-10-06 10:32:35 +04:00
|
|
|
#!/usr/bin/perl
|
2004-11-22 03:37:56 +03:00
|
|
|
#
|
2005-11-05 22:57:48 +03:00
|
|
|
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
# University Research and Technology
|
|
|
|
# Corporation. All rights reserved.
|
|
|
|
# Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
# of Tennessee Research Foundation. All rights
|
|
|
|
# reserved.
|
2015-06-24 06:59:57 +03:00
|
|
|
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
# University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
# Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
# All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
# $COPYRIGHT$
|
2015-06-24 06:59:57 +03:00
|
|
|
#
|
2004-11-22 04:38:40 +03:00
|
|
|
# Additional copyrights may follow
|
2015-06-24 06:59:57 +03:00
|
|
|
#
|
2004-11-22 03:37:56 +03:00
|
|
|
# $HEADER$
|
|
|
|
#
|
2004-10-06 10:32:35 +04:00
|
|
|
|
|
|
|
if (scalar(@ARGV) != 2) {
|
|
|
|
print "Usage:
|
|
|
|
find_offenders.pl <header_file_list> <source_tree_path>
|
|
|
|
eg.,: running from top level source tree
|
|
|
|
#contrib/find_offenders.pl contrib/results.txt .\n";
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
$source_tree = @ARGV[1];
|
|
|
|
$header_file_list = @ARGV[0];
|
|
|
|
|
|
|
|
#first construct the danger list
|
|
|
|
open(FILE_LIST, "$header_file_list") || print "Could not open results.txt\n";
|
|
|
|
open(DANGER_FILES, "> contrib/headers.txt") || print "Could not open headers.txt\n";
|
|
|
|
|
|
|
|
while (<FILE_LIST>) {
|
|
|
|
#check if this file is a file in the source tree
|
|
|
|
chomp($_);
|
|
|
|
$file_name = $_;
|
|
|
|
open(FILE, "find . -name $file_name |") || print "find failed\n";
|
|
|
|
while(<FILE>) {
|
2015-06-24 06:59:57 +03:00
|
|
|
#file is found
|
2004-10-06 10:32:35 +04:00
|
|
|
print DANGER_FILES "#include <$file_name>\n";
|
|
|
|
}
|
|
|
|
close (FILE);
|
|
|
|
}
|
|
|
|
close (DANGER_FILES);
|
|
|
|
close (FILE_LIST);
|
|
|
|
|
|
|
|
open(DANGER_FILES, "contrib/headers.txt") || print "Could not open headers.txt\n";
|
|
|
|
open(OFFENSIVE, "> contrib/offenders.list") || print "Could not open offenders list\n";
|
|
|
|
|
|
|
|
while (<DANGER_FILES>) {
|
|
|
|
|
|
|
|
$header = $_;
|
|
|
|
chomp($header);
|
|
|
|
print;
|
|
|
|
|
|
|
|
open(C_FILES, "find $source_tree -name *.c |") || print "Could not complete find command\n";
|
|
|
|
|
|
|
|
while (<C_FILES>) {
|
|
|
|
$c_file = $_;
|
|
|
|
open(C_FILE, "$c_file") || print "Could not open $_\n";
|
|
|
|
while (<C_FILE>) {
|
|
|
|
if (/$header/) {
|
2015-06-24 06:59:57 +03:00
|
|
|
print OFFENSIVE $header ." --> ". $c_file ;
|
2004-10-06 10:32:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close (C_FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
close (C_FILES);
|
2015-06-24 06:59:57 +03:00
|
|
|
|
2004-10-06 10:32:35 +04:00
|
|
|
open(H_FILES, "find . -name *.h |") || print "Could not complete find command\n";
|
|
|
|
|
|
|
|
while (<H_FILES>) {
|
|
|
|
$h_file = $_;
|
|
|
|
open(H_FILE, "$h_file") || print "Could not open $_\n";
|
|
|
|
while (<H_FILE>) {
|
|
|
|
if (/$header/) {
|
2015-06-24 06:59:57 +03:00
|
|
|
print OFFENSIVE $header ." --> ". $h_file ;
|
2004-10-06 10:32:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
close (H_FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
close (H_FILES);
|
|
|
|
}
|
|
|
|
|
|
|
|
close (DANGER_FILES);
|
|
|
|
close (OFFENSIVE);
|