From: Han-Wen Nienhuys Date: Wed, 29 Nov 2006 16:27:42 +0000 (+0100) Subject: check for superfluous headers. X-Git-Tag: release/2.11.1-1~40 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=7b40209648be40c94713f79ac8fe80dd9fceced8;p=lilypond.git check for superfluous headers. --- diff --git a/buildscripts/find-superfluous-includes.py b/buildscripts/find-superfluous-includes.py new file mode 100644 index 0000000000..ded1087da7 --- /dev/null +++ b/buildscripts/find-superfluous-includes.py @@ -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 + + +