]> thyrsus.com Git - comparator.git/commitdiff
Added -F option.
authorEric S. Raymond <esr@thyrsus.com>
Thu, 11 Mar 2004 01:21:25 +0000 (01:21 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 11 Mar 2004 01:21:25 +0000 (01:21 +0000)
comparator.xml
filterator

index becf0f51f2da67c236a15150de5a56a0cd988091..7dbd34153c749da18d3fcc8e9db0ef964e145d95 100644 (file)
@@ -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.</para>
 
+<para>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.</para>
+
 <para>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.</para>
+reports with -m, -f, and -F options of the tool and then hand-filter
+them for junk before generating a listing.</para>
 
 <para>Each <application>filterator</application> line beginning with %
 is the filename from which the following common span of lines is displayed 
index 4055e5134149319c0eab8db56e9a9bf3089cad2d..6b69ae139530a2ec37e178480d66ab9a6d90da0a 100755 (executable)
@@ -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})