From 1a92bd11c5dab5054703e839e5546bf61ceaa71e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 15 Sep 2003 22:02:09 +0000 Subject: [PATCH] This version passes regress and regress3 --- main.c | 6 +++--- report.c | 12 ++++++------ shred.h | 2 +- shredtree.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/main.c b/main.c index 01a35f7..a3186d1 100644 --- 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); diff --git a/report.c b/report.c index b102df2..e7adbdf 100644 --- 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 4aa3043..83a2f13 100644 --- 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 { diff --git a/shredtree.c b/shredtree.c index adb373d..1401953 100644 --- a/shredtree.c +++ b/shredtree.c @@ -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 -- 2.43.0