diff options
Diffstat (limited to 'source4/script/find_unused_macros.pl')
-rwxr-xr-x | source4/script/find_unused_macros.pl | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/source4/script/find_unused_macros.pl b/source4/script/find_unused_macros.pl index 5c04b1fd88..697afcd1a9 100755 --- a/source4/script/find_unused_macros.pl +++ b/source4/script/find_unused_macros.pl @@ -3,30 +3,36 @@ # it defines that are used nowhere in the code # Arguments: C and H files +# Copyright Jelmer Vernooij <jelmer@samba.org>, GPL -my %defined,%used,%files; +use strict; -$in = shift; +my %defined; +my %used; +my %files; +my $tmp; while($tmp = shift) { $files{$tmp} = $tmp; open(FI, $tmp); + my $ln = 0; while(<FI>) { - $line = $_; - $cur = ""; + $ln++; + my $line = $_; + my $cur = ""; if(/^#define ([A-Za-z0-9_]+)/) { - $defined{$1} = $tmp; + $defined{$1} = "$tmp:$ln"; $cur = $1; } $_ = $line; while(/([A-Za-z0-9_]+)/sgm) { - if($cur cmp $1) { $used{$1} = $tmp; } + if($cur ne $1) { $used{$1} = "$tmp:$ln"; } } } close FI; } foreach(keys %defined) { - if(!$used{$_}) { print "$_\n"; } + if(!$used{$_}) { print "$defined{$_}: Macro `$_' is unused\n"; } } |