From: Eric S. Raymond Date: Thu, 11 Mar 2004 01:21:25 +0000 (+0000) Subject: Added -F option. X-Git-Tag: 2.4~5 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=53f3b36f24264de9f73f53bc51ec4a7f33ec6d6f;p=comparator.git Added -F option. --- diff --git a/comparator.xml b/comparator.xml index becf0f5..7dbd341 100644 --- a/comparator.xml +++ b/comparator.xml @@ -215,9 +215,14 @@ all cliques for which no assocoated filename matches the regexp. This might be useful if you want to see a common-segment report only for files with a particular extension such as .h or .S. +The -F option takes an argument which is a file containing +a list of filenames. Any clique that does not contain one of these +filenames is discarded. + The -n option suppresses code listing, so that an SCF-B output is produced instead. You can use this to filter common-segment -reports with -m and -f options of the tool. +reports with -m, -f, and -F options of the tool and then hand-filter +them for junk before generating a listing. Each filterator line beginning with % is the filename from which the following common span of lines is displayed diff --git a/filterator b/filterator index 4055e51..6b69ae1 100755 --- a/filterator +++ b/filterator @@ -20,20 +20,25 @@ if __name__ == '__main__': # Main line begins here import getopt try: - (optlist, args) = getopt.getopt(sys.argv[1:], 'd:f:m:n') + (optlist, args) = getopt.getopt(sys.argv[1:], 'd:f:F:m:n') except getopt.GetoptError: - sys.stderr.write("usage: filterator [-n] [-d dir] [-m size] [-f filter]\n") + sys.stderr.write("usage: filterator [-n] [-d dir] [-m size] [-f filter] [-F matchfile]\n") sys.exit(2) dir = None filter = None minsize = 5 expand = True + matchfiles = [] linecounts = {} for (opt, val) in optlist: if opt == '-d': dir = val elif opt == '-f': filter = re.compile(val) + elif opt == '-F': + fp = open(val, "r") + matchfiles = map(lambda x: x.strip(), fp.readlines()) + fp.close() elif opt == '-m': minsize = int(val) elif opt == '-n': @@ -45,6 +50,8 @@ if __name__ == '__main__': state.cliquefilter(lambda file,start,end: end-start+1 >= minsize) if filter: state.cliquefilter(lambda file, start, end: filter.search(file)) + if matchfiles: + state.cliquefilter(lambda file, start, end: file in matchfiles) try: if expand: state.metadump(sys.stdout, (75 * '-')+"\n", reporthook, {"Minimum-Size":minsize})