summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdeheader16
-rw-r--r--deheader.xml12
2 files changed, 22 insertions, 6 deletions
diff --git a/deheader b/deheader
index 22faa10..a52e401 100755
--- a/deheader
+++ b/deheader
@@ -1143,8 +1143,10 @@ class InclusionMap:
def c_source(filename):
"Predicate: return true if the filename appears to be C or C++ source."
return filename.endswith(".c") or filename.endswith(".cpp")
- def __init__(self, roots, ignore, verbosity):
+ def __init__(self, roots, ignore, excludes, verbosity):
"Build the initial inclusion map."
+ if excludes:
+ excludes = re.compile(excludes)
self.verbosity = verbosity
self.files = []
compiled = []
@@ -1158,7 +1160,10 @@ class InclusionMap:
compiled.append((r, c, h))
for root in roots:
if not os.path.isdir(root):
- if InclusionMap.c_source(root):
+ if excludes and excludes.search(root):
+ if verbose > 1:
+ print "deheader: %s excluded" % root
+ elif InclusionMap.c_source(root):
self.files.append(root)
else:
print >>sys.stderr, "deheader: can't analyze %s" % root
@@ -1359,13 +1364,14 @@ class Summary:
(len(self.filenames), len(self.includes), len(self.unneeded))
if __name__ == "__main__":
- (options, arguments) = getopt.getopt(sys.argv[1:], "hi:m:rvV",
+ (options, arguments) = getopt.getopt(sys.argv[1:], "hi:m:rvx:V",
["help", "ignore",
"remove", "verbose",])
maker = "make"
verbose = 0
remove = False
ignores = []
+ excludes = None
for (switch, val) in options:
if switch in ('-h', '--help'):
sys.stderr.write(__doc__)
@@ -1381,6 +1387,8 @@ if __name__ == "__main__":
elif switch in ('-V', '--version'):
print "deheader", version
raise SystemExit, 0
+ elif switch in ('-x', '--exclude'):
+ excludes = val
if not ignores:
ignore = None
else:
@@ -1388,7 +1396,7 @@ if __name__ == "__main__":
if not arguments:
arguments = ["."]
- inclusion_map = InclusionMap(arguments, ignore, verbose)
+ inclusion_map = InclusionMap(arguments, ignore, excludes, verbose)
summaries = []
for sourcefile in inclusion_map.depends_on:
summaries.append(deheader(sourcefile, maker,
diff --git a/deheader.xml b/deheader.xml
index ea6044b..cd6375c 100644
--- a/deheader.xml
+++ b/deheader.xml
@@ -20,10 +20,11 @@
<cmdsynopsis>
<command>deheader</command>
<arg choice='opt'>-h </arg>
- <arg choice='opt'>-m </arg>
- <arg choice='opt'>-i </arg>
+ <arg choice='opt'>-m <replaceable>command</replaceable></arg>
+ <arg choice='opt'>-i <replaceable>pattern</replaceable></arg>
<arg choice='opt'>-r </arg>
<arg choice='opt'>-v </arg>
+ <arg choice='opt'>-x <replaceable>pattern</replaceable></arg>
<arg choice='opt'>-V </arg>
<arg choice='opt'><replaceable>file-or-dir</replaceable></arg>
</cmdsynopsis>
@@ -117,6 +118,13 @@ Takes a Python regular expression.</para>
</listitem>
</varlistentry>
<varlistentry>
+<term>-x</term>
+<listitem>
+<para>Exclude files with names matching the specified Python regexp.</para>
+</listitem>
+</varlistentry>
+</variablelist>
+<varlistentry>
<term>-V</term>
<listitem>
<para>Show version of program and exit.</para>