]> thyrsus.com Git - comparator.git/commitdiff
Change everything to use shorts for line indices.
authorEric S. Raymond <esr@thyrsus.com>
Sun, 31 Aug 2003 09:50:50 +0000 (09:50 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Sun, 31 Aug 2003 09:50:50 +0000 (09:50 +0000)
report.c
shredcompare.py
shredtree.c
shredtree.py

index bf8096c5d0855862b84adaccafe08779cad78395..d57bccd019bd404b60e17764eece036f1cbd2c87 100644 (file)
--- a/report.c
+++ b/report.c
@@ -134,7 +134,7 @@ main(int argc, char *argv[])
 
     /* compute total data to be read, we'll use this for the progress meter */
     total = 0;
-    for (sp = shiflist; sp < shiflist + filecount-1; sp++)
+    for (sp = shiflist; sp < shiflist + filecount; sp++)
     {
        stat(sp->name, &sb);
        total += sb.st_size;
@@ -142,4 +142,7 @@ main(int argc, char *argv[])
     fprintf(stderr, "%ld bytes to be read.\n", total);
 
     /* read in all hashes */
+    for (sp = shiflist; sp < shiflist + filecount; sp++)
+    {
+    }
 }
index c9e0e098c6b95204886ea636327d2b602bf34f30..6f85fdbae4a2725d5f7f09077b11bcc8a082f8b8 100755 (executable)
@@ -86,11 +86,11 @@ def merge_hashes(fp, dict):
         return False
     file = file.strip()
     # Record count comes right after the filename
-    (record_count,) = struct.unpack("!i", fp.read(4))
+    (record_count,) = struct.unpack("!H", fp.read(2))
     while record_count > 0:
         record_count -= 1
         # 4 bytes of start line number + 4 of end line number + 16 of MD5 hash
-        (start, end, hashval) = struct.unpack("!ii16s", fp.read(24))
+        (start, end, hashval) = struct.unpack("!HH16s", fp.read(20))
         if dict.has_key(hashval):
             oldval = dict[hashval]
         else:
@@ -155,6 +155,9 @@ if __name__ == '__main__':
     # Compute amount of data to be read
     total = sum(map(filesize, args))
     sys.stderr.write("%d bytes of data to be read\n" % total)
+    # Read in the filecounts, though this implementation won't use them.
+    for shif in shiflist:
+        shif.fp.read(struct.calcsize("!i"))
     # Read in all hashes
     hashdict = bsddb.hashopen(None, 'c')
     for shif in shiflist:
index e5d9f298137132f6a504c72a71dcce147771eac8..0ff4181b39e301b2f85059c6d52ca31ce67224d0 100644 (file)
@@ -187,6 +187,7 @@ main(int argc, char *argv[])
     extern int optind;         /* set by getopt */
 
     int status;
+    u_int32_t  netfilecount;
     char **place, **list, *dir = ".";
     while ((status = getopt(argc, argv, "cd:hs:w")) != EOF)
     {
@@ -244,6 +245,9 @@ main(int argc, char *argv[])
     /* the objective -- sort */
     qsort(list, filecount, sizeof(char *), stringsort);
 
+    /* generate the list */
+    netfilecount = htonl(filecount);
+    fwrite(&netfilecount, sizeof(u_int32_t), 1, stdout);
     for (place = list; place < list + filecount; place++)
        shredfile(*place);
 
index 56b423e7558380b078ad3a6ffd75d1b7e6fb776f..d9b9685efa102ba4cee55790390cd22438d914a4 100755 (executable)
@@ -32,7 +32,7 @@ def emit_chunk(display, file, linecount):
         if debug:
             sys.stderr.write(`line[0]` + "\n")
         m.update(line[0])
-    return struct.pack("!ii", startline, linecount) + m.digest()
+    return struct.pack("!HH", startline, linecount) + m.digest()
 
 def shredfile(file):
     "Emit shred tuples corresponding to a specified file."
@@ -67,7 +67,7 @@ def shredfile(file):
        outdata += emit_chunk(display, file, linecount)
         chunk_count += 1
     # Write the actual data
-    sys.stdout.write(file + "\n" + struct.pack("!i", chunk_count) + outdata)
+    sys.stdout.write(file + "\n" + struct.pack("!H", chunk_count) + outdata)
 
 if __name__ == '__main__':
     try:
@@ -116,6 +116,7 @@ if __name__ == '__main__':
                 if eligible(fullpath):
                     filenames.append(fullpath)
         filenames.sort()
+        sys.stdout.write(struct.pack("!i", len(filenames)))
         for path in filenames:
             shredfile(path)
 # End