]> thyrsus.com Git - comparator.git/commitdiff
Both now have percent prompts.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 2 Sep 2003 08:08:35 +0000 (08:08 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 2 Sep 2003 08:08:35 +0000 (08:08 +0000)
Makefile
report.c
shredcompare.py

index d685582aa4453c9c1d439f2023768f60fafadecf..319113bb024dbb35ed33cfda8090e00d9a781d97 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,15 +19,21 @@ shredcompare: shredcompare.o
 clean:
        rm -f shredtree shredcompare shredtree.o md5.o shredcompare.o
 
-test:
+test-a:
        shredtree -c test1 >TEST1
        shredtree -c test2 >TEST2
        shredcompare TEST1 TEST2
-
-testgood:
+test-b:
        shredtree -c test3 >TEST1
        shredtree -c test4 >TEST2
-       @echo "*** Python;"
-       shredcompare.py TEST1 TEST2
-       @echo "*** C:"
        shredcompare TEST1 TEST2
+
+goodtest:
+       shredtree -c -d ~/src/unix src5r4/src/ucbhead >src5r4.shif
+       shredtree -c -d ~/src/unix linux-2.6.0-test4/include/linux >linux-2.6.0-test4.shif
+       shredcompare src5r4.shif linux-2.6.0-test4.shif >TEST.LOG
+
+bigtest:
+       shredtree -c -d ~/src/unix src5r4 >src5r4.shif
+       shredtree -c -d ~/src/unix linux-2.6.0-test4 >linux-2.6.0-test4.shif
+       shredcompare src5r4.shif linux-2.6.0-test4.shif >TEST.LOG
index 4d27173431899ffcebe3d31ebb38c2936f8fd1dc..761dd43ed48ca3c8f9c13d4283b41b5dafb9723c 100644 (file)
--- a/report.c
+++ b/report.c
@@ -28,6 +28,7 @@ struct shif_t
     int                shred_size;
     char       *hash_method;
     char       *generator_program;
+    int                hashcount;
 };
 static struct shif_t *shiflist;
 
@@ -190,7 +191,6 @@ void init_intern(const int count)
         stat(sp->name, &sb);
         total += sb.st_size - ftell(sp->fp);
      }
-     fprintf(stderr, "%% %ld bytes to be read.\n", total);
      init_intern(total/sizeof(struct hash_t)); /* real work done here */
 
      /* read in all hashes */
@@ -199,6 +199,7 @@ void init_intern(const int count)
      {
         u_int32_t      sectcount;
 
+        fprintf(stderr, "Reading %s...   ", sp->name);
         fread(&sectcount, sizeof(u_int32_t), 1, sp->fp);
         sectcount = ntohl(sectcount);
         while (sectcount--)
@@ -221,8 +222,12 @@ void init_intern(const int count)
                 this.end = FROMNET(this.end);
                 hash_intern(&this);            /* real work done here */
                 hashcount++;
+                sp->hashcount++;
+                if (hashcount % 10000 == 0)
+                    fprintf(stderr, "\b\b\b%02.0f%%", (ftell(sp->fp) / (total * 0.01)));
             }
         }
+        fprintf(stderr, "\b\b\b100%%...done, %d entries\n", sp->hashcount);
      }
  }
 
index a3d3e0c45560fab4031a5e918188a8042e1a636f..8cd61c94615aaf39b034bee94d13eafc8c350771 100755 (executable)
@@ -10,6 +10,7 @@ class SHIF:
         self.name = name
         self.fp = open(name)
         self.comments = []
+        self.hashcount = 0
         id = self.fp.readline()
         if not id.startswith("#SHIF-A "):
             sys.stderr.write("shredcompare: %s is not a SHIF-A file."%self.fp.name)
@@ -78,27 +79,28 @@ class Shred:
 
 hashcount = total = 0
 
-def merge_hashes(fp, dict):
+def merge_hashes(shif, dict):
     "Read and merge hashes corresponding to one file."
     global hashcount
-    file = fp.readline()
+    file = shif.fp.readline()
     if not file:
         return False
     file = file.strip()
     # Record count comes right after the filename
-    (record_count,) = struct.unpack("!H", fp.read(2))
+    (record_count,) = struct.unpack("!H", shif.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("!HH16s", fp.read(20))
+        (start, end, hashval) = struct.unpack("!HH16s", shif.fp.read(20))
         if dict.has_key(hashval):
             oldval = dict[hashval]
         else:
             oldval = ""
         dict[hashval] = oldval + file + "\t" + `start` + "\t" + `end` + "\n"
         hashcount += 1
+        shif.hashcount += 1
         if hashcount % 10000 == 0:
-            sys.stderr.write("\b\b\b%02.0f%%" % (fp.tell() / (total * 0.01)))
+            sys.stderr.write("\b\b\b%02.0f%%" % (shif.fp.tell() / (total * 0.01)))
     return True
 
 def item_factory(db):
@@ -153,17 +155,16 @@ if __name__ == '__main__':
         shiflist[i].compatible(shiflist[i+1])
     # Compute amount of data to be read
     total = sum(map(lambda x: filesize(x.name) - x.fp.tell(), shiflist))
-    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:
-        sys.stderr.write("Reading...   ")
-        while merge_hashes(shif.fp, hashdict):
+        sys.stderr.write("Reading %s...   " % shif.name)
+        while merge_hashes(shif, hashdict):
             continue
-        sys.stderr.write("\b\b\b100%...done\n")
+        sys.stderr.write("\b\b\b100%...done, %d entries\n" % shif->hashcount)
     report_time("Hash merge done, %d entries" % hashcount)
     # Nuke all unique hashes
     nonuniques = 0