diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-12-01 15:39:18 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-12-01 15:39:18 -0500 |
commit | 1a8c525d7fb3c00c373a80a40306e32221836362 (patch) | |
tree | 27c6d2eb8df9787f3a3ef010b77306a8a60d9e85 | |
parent | d993e19e69467e050871971d25f4f9cc5c7d7c1e (diff) | |
download | deheader-1a8c525d7fb3c00c373a80a40306e32221836362.tar.gz deheader-1a8c525d7fb3c00c373a80a40306e32221836362.tar.bz2 deheader-1a8c525d7fb3c00c373a80a40306e32221836362.tar.xz deheader-1a8c525d7fb3c00c373a80a40306e32221836362.zip |
Fix broken processing of --ignore and clean up debug levels.
-rwxr-xr-x | deheader | 29 |
1 files changed, 18 insertions, 11 deletions
@@ -26,6 +26,10 @@ on interrupt or after processing with its original timestamp, unless the import sys, os, tempfile, getopt, time, re +BATON_DEBUG = 1 +PROGRESS_DEBUG = 2 +COMMAND_DEBUG = 3 + class Baton: "Ship progress indications to stderr." def __init__(self, prompt, endmsg=None): @@ -92,16 +96,16 @@ class InclusionMap: elif line.startswith("#endif"): ifdepth -= 1 elif line.startswith("#include"): - if verbosity: + if verbosity >= PROGRESS_DEBUG: name = trim(line) print "deheader: %s requires %s" % (sourcefile, name) - if ignore.search(line): - if verbosity: + if ignore and ignore.search(line): + if verbosity >= PROGRESS_DEBUG: print "deheader: ignoring %s (exclusion match with %s)." % (name, ignore.pattern) continue if ifdepth == 0: includes.append(line) - elif verbose: + elif verbose > 1: print "deheader: ignoring %s (conditional inclusion)" % name self.c_to_h[sourcefile] = includes def forget(self, sourcefile, header): @@ -153,18 +157,18 @@ def testcompile(source, maker, msg="", verbosity=0): if os.path.exists(derived): os.remove(derived) command = maker + " " + derived - if verbosity < 2: + if verbosity < COMMAND_DEBUG: command += " >/dev/null 2>&1" start = time.time() status = os.system(command) end = time.time() if status: explain = "failed" - if verbosity >= 2: + if verbosity >= PROGRESS_DEBUG: explain += " (%d)" % status else: explain = "succeeded" - if verbosity: + if verbosity >= PROGRESS_DEBUG: print "deheader: %s%s %s in %2.2f sec." \ % (sourcefile, msg, explain, end-start) return (status, end - start) @@ -175,7 +179,7 @@ def c_analyze(source, maker, includes, verbosity): # headers might depend on earlier ones includes.reverse() unneeded = [] - if verbosity == 0: + if verbosity == BATON_DEBUG: baton = Baton(sourcefile + ": ", "Done") try: saveit = SaveForModification(sourcefile) @@ -188,13 +192,13 @@ def c_analyze(source, maker, includes, verbosity): unneeded.append(header) includes.remove(header) keepgoing = True - if verbosity == 0: + if verbosity == BATON_DEBUG: baton.twirl() if not keepgoing: break finally: saveit.revert() - if verbosity == 0: + if verbosity == BATON_DEBUG: baton.end() return unneeded @@ -235,7 +239,10 @@ if __name__ == "__main__": remove = True elif switch in ('-v', '--verbose'): verbose += 1 - ignore = re.compile("|".join(ignores)) + if not ignores: + ignore = None + else: + ignore = re.compile("|".join(ignores)) if not arguments: arguments = ["."] |