From d48fe45e935b33feda8904767ad2904ac47453e4 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 1 Sep 2003 19:51:01 +0000 Subject: [PATCH] Fix the comparison function. --- report.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/report.c b/report.c index 2052f90..2327c63 100644 --- 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[]) -- 2.43.0