#include <stdio.h> #include "trie.h" #include "globals.h" #define ALLCHK 0x7FFFFFE unsigned long trielookup(register unsigned long t, register char *s) { register unsigned long *p; foo: if (!*s) return (t); if (!ptr (t)) return (0); p = dawg + ptr (t); do { if (chr (*p) == chr (*s)) { t = *p; s++; goto foo; } } while (!last (*p++)); return (0); } unsigned long checkout (char *s, unsigned long *score) { register unsigned long chek = 0; register unsigned long *p; register char *s1 = s; *score = 0; while (s1[-1]) (*score) += lettervalue[*--s1]; /* now s1 points to top of word */ p = dawg + ptr (trielookup (root, s1)); if (p == dawg) return (0); do if (term (trielookup (*p, s + 1))) chek |= (1 << chr (*p)); while (!last (*p++)); while (s[1]) (*score) += lettervalue[*++s]; return (chek); } void computechecks (char fill[17][17], unsigned long check[17][17], unsigned long trans[17][17]) { unsigned long i, j; for (i = 1; i < 16; i++) for (j = 1; j < 16; j++) { trans[j][i] = -1; check[j][i] = fill[i][j] ? 0 :fill[i][j - 1] || fill[i][j + 1] ? checkout (fill[i] + j, trans[j] + i) :ALLCHK; } }