From: Eric S. Raymond Date: Wed, 3 Sep 2003 09:36:16 +0000 (+0000) Subject: Change the debug option. X-Git-Tag: 1.0~44 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=7839ec2fd4e9991452ad5e6b00e40824ca0298a9;p=comparator.git Change the debug option. --- diff --git a/Makefile b/Makefile index 1a669bf..5ce94d5 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ # Makefile for comparator tools SOURCES = shredtree.c shredcompare.c main.c md5.c md5.h +DOCS = README comparator.xml CFLAGS=-g -all: comparator +all: comparator comparator.1 main.o: main.c shred.h $(CC) -c $(CFLAGS) main.c @@ -18,6 +19,9 @@ comparator: main.o shredtree.o md5.o shredcompare.o clean: rm -f comparator shredtree.o md5.o shredcompare.o TEST1 TEST2 +comparator.1: comparator.xml + xmlto man comparator.xml + test-a: comparator comparator test1 test2 test-b: comparator diff --git a/main.c b/main.c index b9f7513..c9bc862 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,8 @@ #include #include "shred.h" +int debug = 0; + struct scf_t { char *name; @@ -111,7 +113,7 @@ static void merge_tree(char *tree) int oldcount, file_count; oldcount = sort_count; - fprintf(stderr, "%% Reading %s...", tree); + fprintf(stderr, "%% Reading tree %s...", tree); list = sorted_file_list(tree, &file_count); for (place = list; place < list + file_count; place++) shredfile(*place, corehook); diff --git a/report.c b/report.c index d056a7b..4f87348 100644 --- a/report.c +++ b/report.c @@ -45,7 +45,7 @@ void merge_scf(const char *name, FILE *fp) u_int32_t sectcount; int hashcount = 0; - fprintf(stderr, "%% Reading %s... ", name); + fprintf(stderr, "%% Reading hash list %s... ", name); fread(§count, sizeof(u_int32_t), 1, fp); sectcount = ntohl(sectcount); while (sectcount--) @@ -309,30 +309,31 @@ void emit_report(struct sorthash_t *obarray, int hashcount) struct match_t *hitlist, *sorted, *match; int i, matchcount; -#ifdef ODEBUG - struct sorthash_t *np; - - for (np = obarray; np < obarray + hashcount; np++) - printf("%d: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %s:%d:%d\n", - np-obarray, - np->hash.hash[0], - np->hash.hash[1], - np->hash.hash[2], - np->hash.hash[3], - np->hash.hash[4], - np->hash.hash[5], - np->hash.hash[6], - np->hash.hash[7], - np->hash.hash[8], - np->hash.hash[9], - np->hash.hash[10], - np->hash.hash[11], - np->hash.hash[12], - np->hash.hash[13], - np->hash.hash[14], - np->hash.hash[15], - np->file, np->hash.start, np->hash.end); -#endif /* ODEBUG */ + if (debug) + { + struct sorthash_t *np; + + for (np = obarray; np < obarray + hashcount; np++) + printf("%d: %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %s:%d:%d\n", + np-obarray, + np->hash.hash[0], + np->hash.hash[1], + np->hash.hash[2], + np->hash.hash[3], + np->hash.hash[4], + np->hash.hash[5], + np->hash.hash[6], + np->hash.hash[7], + np->hash.hash[8], + np->hash.hash[9], + np->hash.hash[10], + np->hash.hash[11], + np->hash.hash[12], + np->hash.hash[13], + np->hash.hash[14], + np->hash.hash[15], + np->file, np->hash.start, np->hash.end); + } hitlist = reduce_matches(obarray, hashcount); report_time("Reduction done"); diff --git a/shredtree.c b/shredtree.c index 0113bcb..6d6cc6a 100644 --- a/shredtree.c +++ b/shredtree.c @@ -13,7 +13,6 @@ /* control bits, meant to be set at startup */ int c_only = 0; int rws = 0; -int debug = 0; int shredsize = 5; struct item @@ -95,24 +94,6 @@ static struct hash_t emit_chunk(shred *display, int linecount) unsigned char *cp; struct hash_t out; - if (debug) - { - for (i = 0; i < shredsize; i++) - if (display[i].line) - { - fputc('\'', stderr); - for (cp = display[i].line; *cp; cp++) - if (*cp == '\n') - fputs("\\n", stderr); - else if (*cp == '\t') - fputs("\\t", stderr); - else - fputc(*cp, stderr); - fputc('\'', stderr); - fputc('\n', stderr); - } - } - /* build completed chunk onto end of array */ md5_init_ctx(&ctx); for (i = 0; i < shredsize; i++)