/* Copyright 1998,2001 Mark Pulford * This file is subject to the terms and conditions of the GNU General Public * License. Read the file COPYING found in this archive for details, or * visit http://www.gnu.org/copyleft/gpl.html */ /* Check all combinations found in the pit. Policy is decided by the * dictionary file. */ #include #include #include #include #include "lexter.h" #include "words.h" #include "iface.h" #include "list.h" #include "dict.h" #include "lang.h" static char *reverse(char *str, int len); static int word_score(const char *word); static struct list *find_words(const char *str, char *used, int length); static struct list *find_words_dual(const char *str, char *used, int length); static struct word *make_word(const char *w); static char *reverse(char *str, int len) { int i; char t; for(i=0; istr, w, sizeof(p->str)); p->score = word_score(p->str); return p; } struct list *find_pit_words(const struct pit *p, struct pit *u) { char temp[MAXPITSTR]; /* Max string + 1 */ char used[MAXPITSTR]; int x, y, i; struct list *l = NULL; memset(u->pit, 0, PITWIDTH*PITDEPTH); /* Extract and test rows */ for(y=0; ypit[i][y]; memset(used, 0, PITWIDTH); l = list_join(l, find_words_dual(temp, used, PITWIDTH)); for(i=0; ipit[i][y] += used[i]; } /* Extract and test columns */ for(x=0; xpit[x][i]; memset(used, 0, PITDEPTH); l = list_join(l, find_words_dual(temp, used, PITDEPTH)); for(i=0; ipit[x][i] += used[i]; } return l; }