5 struct state *fwd[256], *back, *qnext, *qprev;
10 struct state root, *head, *tail;
12 struct state *step(struct state *s, int c)
24 struct state *s = &root;
26 for (char *y = x; c=*y++; ) {
28 s->fwd[c] = calloc(1, sizeof(struct state));
39 for (int c=0; c<256; c++)
40 if (s = head->fwd[c]) {
41 s->back = step(head->back, c);
52 struct state *s = &root;
53 for (int c; (c = getchar()) != EOF;) {
61 for (struct state *s=tail; s != &root; s=s->qprev) {
62 s->back->count += s->count;
64 printf("%6d %s\n", s->count, s->out);
68 int main(int argc, char **argv)
70 for (int i=1; i<argc; i++)