int main(int argc, char *argv[]) { int i, chg, rev, np; progname = argv[0]; if (argc != 2) { fprintf(stderr, "Usage: %s dict\n", progname); exit(1); } tracef("Started"); readdict(argv[1]); tracef("Dictionary read"); rdict = (Word **)xmalloc(nword*sizeof(Word *)); memcpy(rdict, dict, nword*sizeof(Word *)); qsort(dict, nword, sizeof(Word *), wordcmp); /* sort forwards */ tracef("Sorted fwd"); qsort(rdict, nword, sizeof(Word *), rwordcmp); /* sort backwards */ tracef("Sorted bwd"); for (i=0; i<nword; i++) { dict[i]->map = (1<<(dict[i]->len+1))-1; } tracef("Set map"); rev = FALSE; do { chg = FALSE; for (i=0; i<nword; i++) { if ((rev? check_rword: check_word)(dict[i])) chg = TRUE; } if ((np = purge()) != 0) chg = TRUE; tracef("%d words purged", np); rev = !rev; } while (chg); printdict(dict); return 0; }
static K printq(K x) { K result; if (xt < 0) result = printatom(x); else if ((xt >= 0) && (xt < 20)) result = printlist(x); else if (xt == 98) result = printtable(x); else if (xt == 99) result = printdict(x); else result = krr((S)"notimplemented"); printf("\n"); return result; }
void main(int argc, char **argv) { Bool printout = false; Bool binary = false; Bool convert = false; int opt; extern int optind; argv0 = argv[0]; while((opt = getopt(argc, argv, "cbp")) != EOF) { switch(opt) { case 'c': convert = true; break; case 'b': binary = true; break; case 'p': printout = true; break; default: usage(); } } if(binary && convert) error("what the hey?"); if (optind < argc) dictname = argv[optind]; print("dict..."); if(binary) initbinary(dictname); else initdict(dictname); if(convert) outbinary(dictname); if(printout) { printdict(root,0); exits(0); } print("board..."); initboard(); print("ready\n"); gameplay(); }