1 /*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8 #ifndef lint
9 static char copyright[] =
10 "@(#) Copyright (c) 1991, 1993\n\
11 The Regents of the University of California. All rights reserved.\n";
12 #endif /* not lint */
13
14 #ifndef lint
15 static char sccsid[] = "@(#)spellin.c 8.1 (Berkeley) 06/06/93";
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
main(argc,argv)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