|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)spellin.c 4.1 12/18/82"; ! 3: #endif ! 4: ! 5: #include "spell.h" ! 6: /* add entries to hash table for use by spell ! 7: preexisting hash table is first argument ! 8: words to be added are standard input ! 9: if no hash table is given, create one from scratch ! 10: */ ! 11: ! 12: main(argc,argv) ! 13: char **argv; ! 14: { ! 15: register i, j; ! 16: long h; ! 17: register long *lp; ! 18: char word[NW]; ! 19: register char *wp; ! 20: ! 21: if(!prime(argc,argv)) { ! 22: fprintf(stderr, ! 23: "spellin: cannot initialize hash table\n"); ! 24: exit(1); ! 25: } ! 26: while (fgets(word, sizeof(word), stdin)) { ! 27: for (i=0; i<NP; i++) { ! 28: for (wp = word, h = 0, lp = pow2[i]; ! 29: (j = *wp) != '\0'; ++wp, ++lp) ! 30: h += j * *lp; ! 31: h %= p[i]; ! 32: set(h); ! 33: } ! 34: } ! 35: #ifdef gcos ! 36: freopen((char *)NULL, "wi", stdout); ! 37: #endif ! 38: if (fwrite((char *)tab, sizeof(*tab), TABSIZE, stdout) != TABSIZE) { ! 39: fprintf(stderr, ! 40: "spellin: trouble writing hash table\n"); ! 41: exit(1); ! 42: } ! 43: return(0); ! 44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.