summaryrefslogtreecommitdiff
path: root/source4/script/find_unused_defines.pl
blob: def1bd159f204b62c9c0efb1d854dd3e1edfd235 (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
#!/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: C files pattern

my %symbols;

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

while($tmp = shift) { 
	open(FI, $tmp);
	while(<FI>) { 
		while(/([A-Za-z0-9_]+)/sgm) { 
			$symbols{$1} = 1;
		}
	}
	close FI;
}

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

while(<IN>) {
	if(/AC_DEFINE\(([^,]+),/ and $symbols{$1} != 1) { print "$1\n"; } 
}

close IN;