version 1.4, 1998/04/26 22:49:04 |
version 1.5, 2001/11/19 19:02:18 |
|
|
|
|
#define qinsert(p1, p2) \ |
#define qinsert(p1, p2) \ |
do { \ |
do { \ |
register struct cc *forw = (p1)->qforw; \ |
struct cc *forw = (p1)->qforw; \ |
register struct cc *back = (p1)->qback; \ |
struct cc *back = (p1)->qback; \ |
back->qforw = forw; \ |
back->qforw = forw; \ |
forw->qback = back; \ |
forw->qback = back; \ |
forw = (p2)->qforw; \ |
forw = (p2)->qforw; \ |
|
|
|
|
ccinit() |
ccinit() |
{ |
{ |
register i, j; |
int i, j; |
register struct cc *p; |
struct cc *p; |
|
|
if (tt.tt_token_max > cc_token_max) |
if (tt.tt_token_max > cc_token_max) |
tt.tt_token_max = cc_token_max; |
tt.tt_token_max = cc_token_max; |
|
|
|
|
ccreset() |
ccreset() |
{ |
{ |
register struct cc *p; |
struct cc *p; |
|
|
bzero((char *) cc_htab, HSIZE * sizeof *cc_htab); |
bzero((char *) cc_htab, HSIZE * sizeof *cc_htab); |
for (p = cc_q0a.qforw; p != &cc_q0a; p = p->qforw) |
for (p = cc_q0a.qforw; p != &cc_q0a; p = p->qforw) |
|
|
char *buffer; |
char *buffer; |
struct cc **tokens; |
struct cc **tokens; |
{ |
{ |
register struct cc **pp = tokens; |
struct cc **pp = tokens; |
register i, n; |
int i, n; |
#ifdef STATS |
#ifdef STATS |
int nn, ii; |
int nn, ii; |
#endif |
#endif |
|
|
cc_sweep0(buffer, n, length) |
cc_sweep0(buffer, n, length) |
char *buffer; |
char *buffer; |
{ |
{ |
register char *p; |
char *p; |
register short *hc; |
short *hc; |
register i; |
int i; |
register short c; |
short c; |
register short pc = tt.tt_padc; |
short pc = tt.tt_padc; |
|
|
/* n and length are at least 1 */ |
/* n and length are at least 1 */ |
p = buffer++; |
p = buffer++; |
|
|
cc_sweep(buffer, bufsize, tokens, length) |
cc_sweep(buffer, bufsize, tokens, length) |
char *buffer; |
char *buffer; |
struct cc **tokens; |
struct cc **tokens; |
register length; |
int length; |
{ |
{ |
register struct cc *p; |
struct cc *p; |
register char *cp; |
char *cp; |
register i; |
int i; |
short *hc; |
short *hc; |
short *places = cc_places[length]; |
short *places = cc_places[length]; |
struct cc **pp = tokens; |
struct cc **pp = tokens; |
|
|
struct cc **h; |
struct cc **h; |
|
|
{ |
{ |
register short *hc1 = hc; |
short *hc1 = hc; |
register short c = *cp++; |
short c = *cp++; |
register short hh; |
short hh; |
if ((hh = *hc1) < 0 || c == pc) { |
if ((hh = *hc1) < 0 || c == pc) { |
*hc1++ = -1; |
*hc1++ = -1; |
hc = hc1; |
hc = hc1; |
|
|
} |
} |
for (p = *h; p != 0; p = p->hforw) |
for (p = *h; p != 0; p = p->hforw) |
if (p->length == (char) length) { |
if (p->length == (char) length) { |
register char *p1 = p->string; |
char *p1 = p->string; |
register char *p2 = cp - length; |
char *p2 = cp - length; |
register n = length; |
int n = length; |
do |
do |
if (*p1++ != *p2++) |
if (*p1++ != *p2++) |
goto fail; |
goto fail; |
|
|
if ((*p->hback = p->hforw) != 0) |
if ((*p->hback = p->hforw) != 0) |
p->hforw->hback = p->hback; |
p->hforw->hback = p->hback; |
{ |
{ |
register char *p1 = p->string; |
char *p1 = p->string; |
register char *p2 = cp - length; |
char *p2 = cp - length; |
register n = length; |
int n = length; |
do |
do |
*p1++ = *p2++; |
*p1++ = *p2++; |
while (--n); |
while (--n); |
|
|
} |
} |
|
|
cc_sweep_reverse(pp, places) |
cc_sweep_reverse(pp, places) |
register struct cc **pp; |
struct cc **pp; |
register short *places; |
short *places; |
{ |
{ |
register struct cc *p; |
struct cc *p; |
register short front, back, t; |
short front, back, t; |
|
|
while ((p = *pp++) != 0) { |
while ((p = *pp++) != 0) { |
back = -1; |
back = -1; |
|
|
struct cc **output; |
struct cc **output; |
struct cc **tokens; |
struct cc **tokens; |
{ |
{ |
register i; |
int i; |
|
|
bzero((char *) output, bufsize * sizeof *output); |
bzero((char *) output, bufsize * sizeof *output); |
for (i = 0; i < cc_npass0; i++) |
for (i = 0; i < cc_npass0; i++) |
|
|
} |
} |
|
|
cc_compress_phase1(output, tokens, ntoken, flag) |
cc_compress_phase1(output, tokens, ntoken, flag) |
register struct cc **output; |
struct cc **output; |
struct cc **tokens; |
struct cc **tokens; |
{ |
{ |
register struct cc **pp; |
struct cc **pp; |
#ifdef STATS |
#ifdef STATS |
register int i = 0; |
int i = 0; |
int nt = 0, cc = 0, nc = 0; |
int nt = 0, cc = 0, nc = 0; |
#endif |
#endif |
|
|
|
|
} |
} |
|
|
cc_compress_cleanup(output, bufsize) |
cc_compress_cleanup(output, bufsize) |
register struct cc **output; |
struct cc **output; |
{ |
{ |
register struct cc **end; |
struct cc **end; |
|
|
/* the previous output phase may have been interrupted */ |
/* the previous output phase may have been interrupted */ |
qinsertq(&cc_q0b, &cc_q0a); |
qinsertq(&cc_q0b, &cc_q0a); |
for (end = output + bufsize; output < end;) { |
for (end = output + bufsize; output < end;) { |
register struct cc *p; |
struct cc *p; |
register length; |
int length; |
if ((p = *output) == 0) { |
if ((p = *output) == 0) { |
output++; |
output++; |
continue; |
continue; |
|
|
char flag; |
char flag; |
{ |
{ |
struct cc **pp = tokens; |
struct cc **pp = tokens; |
register struct cc *p = *pp++; |
struct cc *p = *pp++; |
int length = p->length; |
int length = p->length; |
int threshold = thresh(length); |
int threshold = thresh(length); |
#ifndef cc_weight |
#ifndef cc_weight |
|
|
|
|
do { |
do { |
int score; |
int score; |
register struct cc_undo *undop; |
struct cc_undo *undop; |
int ccount; |
int ccount; |
#ifdef STATS |
#ifdef STATS |
int ncover; |
int ncover; |
|
|
ncover = 0; |
ncover = 0; |
#endif |
#endif |
for (i = p->places; i >= 0; i = places[i]) { |
for (i = p->places; i >= 0; i = places[i]) { |
register struct cc **jp; |
struct cc **jp; |
register struct cc *x; |
struct cc *x; |
register struct cc **ip = output + i; |
struct cc **ip = output + i; |
register score0 = initial_score0; |
int score0 = initial_score0; |
struct cc **iip = ip + length; |
struct cc **iip = ip + length; |
struct cc_undo *undop1 = undop; |
struct cc_undo *undop1 = undop; |
|
|
|
|
#endif |
#endif |
p->ccount = ccount; |
p->ccount = ccount; |
} else { |
} else { |
register struct cc_undo *u = cc_undo; |
struct cc_undo *u = cc_undo; |
while (--undop >= u) { |
while (--undop >= u) { |
register struct cc *x; |
struct cc *x; |
if (*undop->pos = x = undop->val) |
if (*undop->pos = x = undop->val) |
x->ccount++; |
x->ccount++; |
} |
} |
|
|
} |
} |
|
|
cc_output_phase(buffer, output, bufsize) |
cc_output_phase(buffer, output, bufsize) |
register char *buffer; |
char *buffer; |
register struct cc **output; |
struct cc **output; |
register bufsize; |
int bufsize; |
{ |
{ |
register i; |
int i; |
register struct cc *p, *p1; |
struct cc *p, *p1; |
|
|
for (i = 0; i < bufsize;) { |
for (i = 0; i < bufsize;) { |
if ((p = output[i]) == 0) { |
if ((p = output[i]) == 0) { |