]> thyrsus.com Git - comparator.git/commitdiff
Fix the comparison function.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 1 Sep 2003 19:51:01 +0000 (19:51 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 1 Sep 2003 19:51:01 +0000 (19:51 +0000)
report.c

index 2052f90e17fb2d1132fcadec6ebb74aa7d6087ca..2327c636855006c477ede873d0fbeb3fe846ffd3 100644 (file)
--- a/report.c
+++ b/report.c
@@ -311,7 +311,18 @@ struct match_t *reduce_matches(int localdups)
 int sortchunk(void *a, void *b)
 /* sort by hash */
 {
-    return HASHCMP((struct sorthash_t *)a, (struct sorthash_t *)b);
+    int cmp = HASHCMP((struct sorthash_t *)a, (struct sorthash_t *)b);
+
+    /*
+     * Using the file name as a secondary key implies that, later on when
+     * we use sort adjacency to build a duplicates list, the duplicates
+     * will be ordered by filename -- thus, implicitly, by tree of origin.
+     */
+    if (cmp)
+       return(cmp);
+    else
+       return(strcmp(((struct sorthash_t *)a)->file,
+                     ((struct sorthash_t *)b)->file));
 }
 
 main(int argc, char *argv[])