summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdeheader12
1 files changed, 7 insertions, 5 deletions
diff --git a/deheader b/deheader
index 2d77881..4167432 100755
--- a/deheader
+++ b/deheader
@@ -4,7 +4,7 @@ deheader -- find (optionally remove) unneeded includes in C or C++ sourcefiles.
Usage: deheader [-h] [-v] [-r] [-i str] sourcefiles
-h, --help Emit this help message and quit.
- -i, --ignore Ignore (don't remove) headers containing the arg string
+ -i, --ignore Ignore (don't remove) headers matching the argument regexp
-r, --remove Remove the final set of unneeded headers
-v, --verbose Be chatty about what you're doing.
@@ -18,7 +18,7 @@ on interrupt or after processing with its original timestamp, unless the
-r option was given and headers removed.
"""
-import sys, os, tempfile, getopt, time
+import sys, os, tempfile, getopt, time, re
def trim(line):
"Get file reference from an #include, retaining <> if a system header."
@@ -36,9 +36,11 @@ def extract_includes(sourcefile, ignores):
for line in open(sourcefile):
if line.startswith("#include"):
if verbose:
- print "deheader: %s requires %s" % (sourcefile, `line`)
+ print "deheader: %s requires %s" % (sourcefile, trim(line))
for stopper in ignores:
- if stopper in line:
+ if stopper.search(line):
+ if verbose:
+ print "deheader: ignoring %s" % (trim(line))
break
else:
includes.append(line)
@@ -107,7 +109,7 @@ if __name__ == "__main__":
sys.stderr.write(__doc__)
sys.exit(0)
elif switch in ('-i', '--ignore'):
- ignores.append(val)
+ ignores.append(re.compile(val))
elif switch in ('-r', '--remove'):
remove = True
elif switch in ('-v', '--verbose'):