]> thyrsus.com Git - comparator.git/commitdiff
Change the debug option.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 2003 09:36:16 +0000 (09:36 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 3 Sep 2003 09:36:16 +0000 (09:36 +0000)
Makefile
main.c
report.c
shredtree.c

index 1a669bfa89b77ce42e6756cc49f2e03fa7f6792e..5ce94d58795811edbb8e70cbae7351e8d0a973d2 100644 (file)
--- 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 b9f751387116217998703ed3e81731c91fd16891..c9bc862ed95f65e37031f380b5892b77377126f6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -6,6 +6,8 @@
 #include <string.h>
 #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);
index d056a7b1298b8eb16529c3942d1cfa0420bdf1ac..4f87348a70cce9708dbba2da38ee1853b39d8726 100644 (file)
--- 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(&sectcount, 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");
index 0113bcb0ee9a6003ef812486a7127bd96afceb1d..6d6cc6a671d863069df525a5aca7a36f7980994c 100644 (file)
@@ -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++)