diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2003-08-16 05:20:22 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2003-08-16 05:20:22 +0000 |
commit | d55de7a15934203cf51ce9eb7e8c07d8e2d3bc2f (patch) | |
tree | 4c8ec34a8f436e59754e4bfe969f7c3dc3110235 | |
parent | d9aa5b15d3bdeb2229b07ccba33cbae55d63f353 (diff) | |
download | samba-d55de7a15934203cf51ce9eb7e8c07d8e2d3bc2f.tar.gz samba-d55de7a15934203cf51ce9eb7e8c07d8e2d3bc2f.tar.bz2 samba-d55de7a15934203cf51ce9eb7e8c07d8e2d3bc2f.zip |
Add script that reports unused macros/defines
(This used to be commit dd850b5bd8abc123f455b715fb62dd4d54297178)
-rwxr-xr-x | source4/script/find_unused_macros.pl | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source4/script/find_unused_macros.pl b/source4/script/find_unused_macros.pl new file mode 100755 index 0000000000..49fe0973db --- /dev/null +++ b/source4/script/find_unused_macros.pl @@ -0,0 +1,33 @@ +#!/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: C and H files + +my %defined,%used,%files; + +# First, make a list of defines in configure +$in = shift; + +while($tmp = shift) { + $files{$tmp} = $tmp; + open(FI, $tmp); + while(<FI>) { + $line = $_; + $cur = ""; + if(/^#define ([A-Za-z0-9_]+)/) { + $defined{$1} = $tmp; + $cur = $1; + } + + $_ = $line; + while(/([A-Za-z0-9_]+)/sgm) { + if($cur cmp $1) { $used{$1} = $tmp; } + } + } + close FI; +} + +foreach(keys %defined) { + if(!$used{$_}) { print "$_\n"; } +} |