puts("Merge-Program: comparator " VERSION);
printf("Normalization: %s\n", scflist->normalization);
printf("Shred-Size: %d\n", scflist->shred_size);
- puts("%%");
- for (scf = scflist; scf->next; scf = scf->next)
- printf("%s:%d\n", scf->name, scf->totallines);
- puts("%%");
report_time("Hash merge done, %d shreds", sort_count);
sort_hashes(sort_buffer, sort_count);
report_time("Sort done");
- emit_report(sort_buffer, sort_count);
+
+ emit_report1(sort_buffer, sort_count);
+
+ puts("%%");
+ for (scf = scflist; scf->next; scf = scf->next)
+ printf("%s:%d:%d:%d\n",
+ scf->name,
+ match_count(scf->name),
+ line_count(scf->name),
+ scf->totallines);
+ puts("%%");
+
+ emit_report2();
exit(0);
}
return(0);
}
-void emit_report(struct sorthash_t *obarray, int hashcount)
-/* report our results */
+static struct match_t *hitlist;
+static int mergecount;
+
+void emit_report1(struct sorthash_t *obarray, int hashcount)
+/* report our results (header portion) */
{
- struct match_t *hitlist, *match, *copy;
- int mergecount;
+ struct match_t *match, *copy;
hitlist = reduce_matches(obarray, &hashcount);
if (debug)
if (match->nmatches > 0 && copy < match)
*copy++ = *match;
mergecount = (copy - hitlist);
+
+ printf("Matches: %d\n", mergecount);
+ }
+
+void emit_report2(void)
+/* report our results (matches) */
+{
+ struct match_t *match;
+
qsort(hitlist, mergecount, sizeof(struct match_t), sortmatch);
for (match = hitlist; match < hitlist + mergecount; match++)
/* free(hitlist); */
}
+int match_count(const char *name)
+/* return count of matches with given tree in them */
+{
+ struct match_t *match;
+ int i, count = 0;
+
+ for (match = hitlist; match < hitlist + mergecount; match++)
+ for (i=0; i < match->nmatches; i++)
+ if (strncmp(name, match->matches[i].file->name, strlen(name)))
+ {
+ count++;
+ break;
+ }
+
+ return(count);
+}
+
+int line_count(const char *name)
+/* return number of lines from given tree in matching segments */
+{
+ struct match_t *match;
+ int i, count = 0;
+
+ for (match = hitlist; match < hitlist + mergecount; match++)
+ for (i=0; i < match->nmatches; i++)
+ if (strncmp(name, match->matches[i].file->name, strlen(name)))
+ {
+ count += match->matches[i].hash.end - match->matches[i].hash.start + 1;
+ break;
+ }
+
+ return(count);
+}
+
+
/* report.c ends here */
</variablelist>
<para>The data section consists of a statistics block followed by a
-sequence of range sets. The statistics block consists of ant number
+sequence of range sets. The statistics block consists of any number
of count lines followed by a %%\n section marker. Each linecount line
-consists of two colon-separated fields, a tree name and a line count.</para>
+consists of four colon-separated fields,
+
+<orderedlist>
+<listitem><para>The name of a tree</para></listitem>
+<listitem><para>A count of chunks containing files from the tree</para></listitem>
+<listitem><para>A count of common lines from the tree</para></listitem>
+<listitem><para>The total line count of the tree</para></listitem>
+</orderedlist>
+
+
+
+a tree name and a line count.</para>
<para>Each range set consists of two or more ranges followed by a line
containing a %%\n section marker. A range is represented as four
extern void sort_hashes(struct sorthash_t *hashlist, int hashcount);
/* shredcompare.c functions */
-extern void emit_report(struct sorthash_t *obarray, int hashcount);
+extern void emit_report1(struct sorthash_t *obarray, int hashcount);
+extern void emit_report2(void);
+extern int match_count(const char *name);
+extern int line_count(const char *name);
/* shred.h ends here */