1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 char copyright[] = 10 "@(#) Copyright (c) 1991 The Regents of the University of California.\n\ 11 All rights reserved.\n"; 12 #endif /* not lint */ 13 14 #ifndef lint 15 static char sccsid[] = "@(#)spellin.c 4.3 (Berkeley) 04/18/91"; 16 #endif /* not lint */ 17 18 #include "spell.h" 19 /* add entries to hash table for use by spell 20 preexisting hash table is first argument 21 words to be added are standard input 22 if no hash table is given, create one from scratch 23 */ 24 25 main(argc,argv) 26 int argc; 27 char **argv; 28 { 29 register i, j; 30 long h; 31 register long *lp; 32 char word[NW]; 33 register char *wp; 34 35 if(!prime(argc,argv)) { 36 fprintf(stderr, 37 "spellin: cannot initialize hash table\n"); 38 exit(1); 39 } 40 while (fgets(word, sizeof(word), stdin)) { 41 for (i=0; i<NP; i++) { 42 for (wp = word, h = 0, lp = pow2[i]; 43 (j = *wp) != '\0'; ++wp, ++lp) 44 h += j * *lp; 45 h %= p[i]; 46 set(h); 47 } 48 } 49 #ifdef gcos 50 freopen((char *)NULL, "wi", stdout); 51 #endif 52 if (fwrite((char *)tab, sizeof(*tab), TABSIZE, stdout) != TABSIZE) { 53 fprintf(stderr, 54 "spellin: trouble writing hash table\n"); 55 exit(1); 56 } 57 return(0); 58 } 59