summaryrefslogtreecommitdiff
path: root/source4/script/find_unused_header_checks.pl
blob: 3caf9da453d44b80922bc4003f1f92f2774f9ce7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
# Script that reads in configure and outputs the names of all the defines 
# it defines that are used nowhere in the code

# Arguments:
#  1: configure.in
#  2: header files
#
# You might want to specify configure.in again in the list of header files 
# as well, because it also uses some includes.

my %symbols;

# First, make a list of defines in configure
$in = shift;

while($tmp = shift) { 
	open(FI, $tmp);
	while(<FI>) { 
		while(/\#([ \t]*)include <(.*)>/sgm) { 
			$symbols{$2} = 1;
		}
	}
	close FI;
}

open(IN, $in) or die("Can't open $in");

while(<IN>) {
	if(/AC_CHECK_HEADERS\(([\[]*)(.*)([\]]*)\)/) {
		@hs = split / /, $2;
		foreach(@hs) { 
			if($symbols{$_} != 1) { print "|$_|\n"; }
		}
	}
}

close IN;