EXTRAS = shredtree.py shredcompare.py
TEST = test
SOURCES = $(CODE) $(DOCS) $(EXTRAS) $(TEST) comparator.spec Makefile
-CFLAGS = -O
+CFLAGS = -O -Wall
LDFLAGS =
all: comparator comparator.1
#include <stdlib.h>
#include <sys/stat.h>
#include <errno.h>
+#include <time.h>
#include "shred.h"
int debug = 0;
{
char **place, **list;
int file_count, progress, totalchunks;
- u_int32_t netfile_count, lines, totallines = 0;
+ u_int32_t netfile_count, totallines = 0;
char buf[BUFSIZ];
list = sorted_file_list(tree, &file_count);
static void read_scf(struct scf_t *scf)
/* merge hashes from specified files into an in-code list */
{
- u_int32_t filecount, totallines;
+ u_int32_t filecount;
int hashcount = 0;
struct stat sb;
int status, file_only, compile_only, argcount;
struct scf_t *scf;
char *dir, *outfile;
- struct sorthash_t *np;
compile_only = file_only = 0;
dir = outfile = NULL;
/* two or more arguments */
for(; optind < argc; optind++)
{
- char *olddir, *source = argv[optind];
+ char *olddir = NULL, *source = argv[optind];
scf = (struct scf_t *)calloc(sizeof(struct scf_t), 1);
scf->next = scflist;
struct match_t *reduce_matches(struct sorthash_t *obarray, int *hashcountp)
/* assemble list of duplicated hashes */
{
- static struct match_t dummy;
- struct match_t *reduced, *sp, *tp;
unsigned int nonuniques, nreduced, progress, hashcount = *hashcountp;
struct sorthash_t *mp, *np;
+ struct match_t *reduced;
if (debug)
dump_array("Chunk list before reduction.\n",obarray, hashcount);
reduced = (struct match_t *)malloc(sizeof(struct match_t) * nreduced);
for (np = obarray; np < obarray + hashcount; np = mp)
{
- struct match_t *new;
int i, heterogenous, nmatches;
if (!debug && progress++ % 10000 == 0)
printf("*** %d has %d in its clique\n", np-obarray, nmatches);
for (i = 0; i < nmatches; i++)
printf("%d: %s:%d:%d\n",
- np-obarray+i, np[i].file, np[i].hash.start, np[i].hash.end);
+ np-obarray+i, np[i].file->name, np[i].hash.start, np[i].hash.end);
}
/* passed all tests, keep this set of ranges */
/* shred.h -- types for shred similarity tools */
#include <sys/types.h>
+#include <netinet/in.h>
/*
* 65,536 lines should be enough, but maybe someday this will be 32 bits.
#include <errno.h>
#include <ctype.h>
#include <stdlib.h>
-#include <netinet/in.h>
#include "md5.h"
#include "shred.h"
/* normalize a buffer in place, return 0 if it should be skipped */
{
if (remove_comments)
+ {
if (remove_braces) /* remove C comments */
{
char *ss = strstr(buf, "//");
if (ss)
*ss = '\0';
}
+ }
if (remove_whitespace) /* strip whitespace, ignore blank lines */
{
if ((fp = fopen(file->name, "r")) == NULL)
{
fprintf(stderr, "shredtree: couldn't open %s, error %d\n",
- file, errno);
+ file->name, errno);
exit(1);
}