version 1.42, 2003/07/23 22:01:36 |
version 1.43, 2003/07/27 07:39:52 |
|
|
static long *ixnew; /* will be overlaid on file[1] */ |
static long *ixnew; /* will be overlaid on file[1] */ |
static long *ixold; /* will be overlaid on klist */ |
static long *ixold; /* will be overlaid on klist */ |
static struct cand *clist; /* merely a free storage pot for candidates */ |
static struct cand *clist; /* merely a free storage pot for candidates */ |
|
static int clistlen; /* the length of clist */ |
static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ |
static struct line *sfile[2]; /* shortened by pruning common prefix/suffix */ |
static u_char *chrtran; /* translation table for case-folding */ |
static u_char *chrtran; /* translation table for case-folding */ |
static struct context_vec *context_vec_start; |
static struct context_vec *context_vec_start; |
|
|
static int newcand(int, int, int); |
static int newcand(int, int, int); |
static int search(int *, int, int); |
static int search(int *, int, int); |
static int skipline(FILE *); |
static int skipline(FILE *); |
|
static int isqrt(int); |
static int stone(int *, int, int *, int *); |
static int stone(int *, int, int *, int *); |
static int readhash(FILE *); |
static int readhash(FILE *); |
static int files_differ(FILE *, FILE *, int); |
static int files_differ(FILE *, FILE *, int); |
|
static __inline int min(int, int); |
|
static __inline int max(int, int); |
|
|
|
|
/* |
/* |
* chrtran points to one of 2 translation tables: cup2low if folding upper to |
* chrtran points to one of 2 translation tables: cup2low if folding upper to |
* lower case clow2low if not folding case |
* lower case clow2low if not folding case |
|
|
class = erealloc(class, (slen[0] + 2) * sizeof(int)); |
class = erealloc(class, (slen[0] + 2) * sizeof(int)); |
|
|
klist = emalloc((slen[0] + 2) * sizeof(int)); |
klist = emalloc((slen[0] + 2) * sizeof(int)); |
clist = emalloc(sizeof(cand)); |
clistlen = 100; |
|
clist = emalloc(clistlen * sizeof(cand)); |
i = stone(class, slen[0], member, klist); |
i = stone(class, slen[0], member, klist); |
free(member); |
free(member); |
free(class); |
free(class); |
|
|
c[j] = -1; |
c[j] = -1; |
} |
} |
|
|
|
/* Code taken from ping.c */ |
static int |
static int |
|
isqrt(int n) |
|
{ |
|
int y, x = 1; |
|
|
|
if (n == 0) |
|
return(0); |
|
|
|
do { /* newton was a stinker */ |
|
y = x; |
|
x = n / x; |
|
x += y; |
|
x /= 2; |
|
} while ((x - y) > 1 || (x - y) < -1); |
|
|
|
return (x); |
|
} |
|
|
|
static int |
stone(int *a, int n, int *b, int *c) |
stone(int *a, int n, int *b, int *c) |
{ |
{ |
int i, k, y, j, l; |
int i, k, y, j, l; |
int oldc, tc, oldl; |
int oldc, tc, oldl; |
|
u_int loopcount; |
|
|
|
const u_int bound = dflag ? UINT_MAX : max(256, isqrt(n)); |
|
|
k = 0; |
k = 0; |
c[0] = newcand(0, 0, 0); |
c[0] = newcand(0, 0, 0); |
|
|
y = -b[j]; |
y = -b[j]; |
oldl = 0; |
oldl = 0; |
oldc = c[0]; |
oldc = c[0]; |
|
loopcount = 0; |
do { |
do { |
|
loopcount++; |
if (y <= clist[oldc].y) |
if (y <= clist[oldc].y) |
continue; |
continue; |
l = search(c, k, y); |
l = search(c, k, y); |
|
|
k++; |
k++; |
break; |
break; |
} |
} |
} while ((y = b[++j]) > 0); |
} while ((y = b[++j]) > 0 && loopcount < bound); |
} |
} |
return (k); |
return (k); |
} |
} |
|
|
{ |
{ |
struct cand *q; |
struct cand *q; |
|
|
clist = erealloc(clist, ++clen * sizeof(cand)); |
if (clen == clistlen) { |
q = clist + clen - 1; |
clistlen = clistlen * 11 / 10; |
|
clist = erealloc(clist, clistlen * sizeof(cand)); |
|
} |
|
q = clist + clen; |
q->x = x; |
q->x = x; |
q->y = y; |
q->y = y; |
q->pred = pred; |
q->pred = pred; |
return (clen - 1); |
return (clen++); |
} |
} |
|
|
static int |
static int |