From 5f6585c9178837f1fb71f5103081150703789554 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 12 Sep 2003 10:17:48 +0000 Subject: [PATCH] Ready to ship the fixed version. --- scf-standard.xml | 13 +++++++++---- shredcompare.py | 9 +++++++-- shredtree.py | 8 +++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/scf-standard.xml b/scf-standard.xml index f0a7bf6..ee128d9 100644 --- a/scf-standard.xml +++ b/scf-standard.xml @@ -324,10 +324,15 @@ comparisons. -The data section consists of a sequence of range sets. Each range set -consists of two or more ranges followed by a line containing a %%\n -section marker. A range is represented as three tab-separated fields: -filename, start line, and end line. Line numbers are 1-origin. +The data section consists of a statistics block followed by a +sequence of range sets. The statistics block consists of ant number +of count lines followed by a %%\n section marker. Each linecount line +consists of two colon-separated fields, a tree name and a line count. + +Each range set consists of two or more ranges followed by a line +containing a %%\n section marker. A range is represented as three +tab-separated fields: filename, start line, and end line. Line +numbers are 1-origin. The natural sort order for range sets is by filename, then by start line, then by end line. Ranges within range sets should be diff --git a/shredcompare.py b/shredcompare.py index 69a259e..49d2d83 100755 --- a/shredcompare.py +++ b/shredcompare.py @@ -9,6 +9,7 @@ class SCF: def __init__(self, name): self.name = name self.fp = open(name) + shif.totallines = 0 self.comments = [] self.hashcount = 0 id = self.fp.readline() @@ -100,6 +101,7 @@ def merge_hashes(shif, dict): shif.hashcount += 1 if hashcount % 10000 == 0: sys.stderr.write("\b\b\b%02.0f%%" % (shif.fp.tell() / (total * 0.01))) + (shif.totallines,) = struct.unpack("!i", shif.fp.read(4)) return True def item_factory(db): @@ -239,12 +241,15 @@ if __name__ == '__main__': print "After sorting:", matches report_time("Reduction done") # OK, dump all matches. - print "#SCF-B 1.0" + print "#SCF-B 1.1" print "Hash-Method: MD5" print "Normalization:", ",".join(shiflist[0].normalization) - print "Merge-Program: shredcompare.py 1.0" + print "Merge-Program: shredcompare.py 1.1" print "Shred-Size: %d" % shiflist[0].shredsize print "%%" + for shif in shiflist: + print "%s:%d" % (shif.name,shif.totallines) + print "%%" # FIXME: do something appropriate with comments for match in matches: for range in match: diff --git a/shredtree.py b/shredtree.py index 232019a..9a6ebd5 100755 --- a/shredtree.py +++ b/shredtree.py @@ -99,7 +99,7 @@ if __name__ == '__main__': elif opt == '-x': debug = True if args: - print "#SCF-A 1.0" + print "#SCF-A 1.1" print "Generator-Program: shredtree.py 1.0" print "Hash-Method: MD5" print "Normalization: %s" % ",".join(normalization); @@ -108,7 +108,8 @@ if __name__ == '__main__': if ws: normalization.append("remove_whitespace") if not normalization: normalization.append("none") - print "%%" + print "%%" + totalbytes = 0 filenames = [] for root, dirs, files in os.walk(args[0]): for file in files: @@ -118,5 +119,6 @@ if __name__ == '__main__': filenames.sort() sys.stdout.write(struct.pack("!i", len(filenames))) for path in filenames: - shredfile(path) + totalbytes = totalbytes + shredfile(path) + sys.stdout.write(struct.pack("!i", totalbytes)) # End -- 2.43.0