]> thyrsus.com Git - comparator.git/commitdiff
This version passes regress and regress3
authorEric S. Raymond <esr@thyrsus.com>
Mon, 15 Sep 2003 22:02:09 +0000 (22:02 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 15 Sep 2003 22:02:09 +0000 (22:02 +0000)
main.c
report.c
shred.h
shredtree.c

diff --git a/main.c b/main.c
index 01a35f7aae5a274536ec3fc5d51e3e9a68d4dc0a..a3186d1642c91a75bd82b283889525e6ce9b87e1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -130,7 +130,7 @@ static void write_scf(const char *tree, FILE *ofp)
        exit(1);
     }
 
-    fputs("#SCF-A 1.1\n", ofp);
+    fputs("#SCF-A 2.0\n", ofp);
     fputs("Generator-Program: comparator 1.0\n", ofp);
     fputs("Hash-Method: MD5\n", ofp);
     write_options(buf);
@@ -355,7 +355,7 @@ void dump_array(const char *legend,
 {
     struct sorthash_t  *np;
 
-    fputs(legend, stderr);
+    fputs(legend, stdout);
     for (np = obarray; np < obarray + hashcount; np++)
     {
        struct hash_t scratch;
@@ -617,7 +617,7 @@ main(int argc, char *argv[])
            dump_array("Consolidated hash list:\n", sort_buffer, sort_count);
 
        /* now we're ready to emit the report */
-       puts("#SCF-B 1.1");
+       puts("#SCF-B 2.0");
        printf("Hash-Method: %s\n", scflist->hash_method);
        puts("Merge-Program: comparator " VERSION);
        printf("Normalization: %s\n", scflist->normalization);
index b102df2c3e5c3dc646251bb47ce741ad17652c1c..e7adbdfef4f161ef9bb56d78018a3535195e701d 100644 (file)
--- a/report.c
+++ b/report.c
@@ -219,8 +219,8 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
       * point to the same tree.  We'll discard those in the next
       * phase.  This costs less time than one might think; without it,
       * the clique detector in the next phase would have to do an
-      * extra HASHCMP per array slot to detect clique boundaries.  Net
-      * cost of this optimization is thus *one* HASHCMP per entry.
+      * extra SORTHASHCMP per array slot to detect clique boundaries.  Net
+      * cost of this optimization is thus *one* SORTHASHCMP per entry.
       * The benefit is that it kicks lots of shreds out, reducing the
       * total working set at the time we build match lists.  The idea
       * here is to avoid swapping, because typical data sets are so
@@ -229,12 +229,12 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
       *
       * The technique: first mark...
       */
-     if (HASHCMP(obarray, obarray+1))
+     if (SORTHASHCMP(obarray, obarray+1))
         obarray[0].hash.start = UNIQUE_FLAG;
      for (np = obarray+1; np < obarray + hashcount-1; np++)
-        if (HASHCMP(np, np-1) && HASHCMP(np, np+1))
+        if (SORTHASHCMP(np, np-1) && SORTHASHCMP(np, np+1))
             np->hash.start = UNIQUE_FLAG;
-     if (HASHCMP(obarray+hashcount-2, obarray+hashcount-1))
+     if (SORTHASHCMP(obarray+hashcount-2, obarray+hashcount-1))
         obarray[hashcount-1].hash.start = UNIQUE_FLAG;
      /* ...then sweep. */
      for (mp = np = obarray; np < obarray + hashcount; np++)
@@ -266,7 +266,7 @@ struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
         /* count the number of hash matches */
         nmatches = 1;
         for (mp = np+1; mp < obarray + hashcount; mp++)
-            if (HASHCMP(np, mp))
+            if (SORTHASHCMP(np, mp))
                 break;
             else
                 nmatches++;
diff --git a/shred.h b/shred.h
index 4aa30435622cf5da31c335c378f3d3c6b683d5d9..83a2f13db81b210fdcbb3660b0a8598d076935f5 100644 (file)
--- a/shred.h
+++ b/shred.h
@@ -29,7 +29,7 @@ struct hash_t
     linenum_t          start, end;
     unsigned char      hash[HASHSIZE];
 };
-#define HASHCMP(s, t)  memcmp((s)->hash.hash, (t)->hash.hash, HASHSIZE)
+#define SORTHASHCMP(s, t)      memcmp((s)->hash.hash, (t)->hash.hash, HASHSIZE)
 
 struct filehdr_t
 {
index adb373d8b266a5d1d0018005c03adc7a39fcaefa..1401953090299d1741a9d6ecd01063f9ee94a84d 100644 (file)
@@ -291,7 +291,7 @@ char **sorted_file_list(const char *tree, int *fc)
 static int sortchunk(const void *a, const void *b)
 /* sort by hash */
 {
-    int cmp = HASHCMP((struct sorthash_t *)a, (struct sorthash_t *)b);
+    int cmp = SORTHASHCMP((struct sorthash_t *)a, (struct sorthash_t *)b);
 
     /*
      * Using the file name as a secondary key implies that, later on when