Add script that detects useless AC_DEFINE()'s in configure.in
authorJelmer Vernooij <jelmer@samba.org>
Sat, 16 Aug 2003 02:24:33 +0000 (02:24 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 16 Aug 2003 02:24:33 +0000 (02:24 +0000)
source/script/find_unused_defines.pl [new file with mode: 0755]

diff --git a/source/script/find_unused_defines.pl b/source/script/find_unused_defines.pl
new file mode 100755 (executable)
index 0000000..def1bd1
--- /dev/null
@@ -0,0 +1,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;