1 #ifndef lint 2 static char sccsid[] = "@(#)spellin.c 4.2 02/02/91"; 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 int argc; 14 char **argv; 15 { 16 register i, j; 17 long h; 18 register long *lp; 19 char word[NW]; 20 register char *wp; 21 22 if(!prime(argc,argv)) { 23 fprintf(stderr, 24 "spellin: cannot initialize hash table\n"); 25 exit(1); 26 } 27 while (fgets(word, sizeof(word), stdin)) { 28 for (i=0; i<NP; i++) { 29 for (wp = word, h = 0, lp = pow2[i]; 30 (j = *wp) != '\0'; ++wp, ++lp) 31 h += j * *lp; 32 h %= p[i]; 33 set(h); 34 } 35 } 36 #ifdef gcos 37 freopen((char *)NULL, "wi", stdout); 38 #endif 39 if (fwrite((char *)tab, sizeof(*tab), TABSIZE, stdout) != TABSIZE) { 40 fprintf(stderr, 41 "spellin: trouble writing hash table\n"); 42 exit(1); 43 } 44 return(0); 45 } 46