]> git.donarmstrong.com Git - lilypond.git/commitdiff
check for superfluous headers.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Nov 2006 16:27:42 +0000 (17:27 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 29 Nov 2006 16:27:42 +0000 (17:27 +0100)
buildscripts/find-superfluous-includes.py [new file with mode: 0644]

diff --git a/buildscripts/find-superfluous-includes.py b/buildscripts/find-superfluous-includes.py
new file mode 100644 (file)
index 0000000..ded1087
--- /dev/null
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+import sys
+import re
+import os
+
+
+full_paths = {}
+incs = {}
+inc_re = re.compile ('^#include "([^"]+)"')
+def parse_file (fn):
+    lst = []
+
+    lc = 0
+    for l in open (fn).readlines():
+        lc += 1
+        m = inc_re.search (l)
+        if m:
+            lst.append ((lc, m.group (1)))
+
+    base = os.path.split (fn)[1]
+    full_paths[base] = fn
+    incs[base] = lst
+    
+
+def has_include (f, name):
+    try:
+        return name in [b for (a,b) in incs[f]]
+    except KeyError:
+        return False
+
+for a in sys.argv:
+    parse_file (a)
+
+print '-*-compilation-*-'
+for (f, lst) in incs.items ():
+    for (n, inc) in lst:
+        for (n2, inc2) in lst:
+            if has_include (inc2, inc):
+                print "%s:%d: already have %s from %s" % (full_paths[f], n,
+                                                          inc, inc2)
+                break
+
+        
+