date and time created 82/12/18 15:10:34 by sam
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 19 Dec 1982 07:10:34 +0000 (23:10 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Sun, 19 Dec 1982 07:10:34 +0000 (23:10 -0800)
SCCS-vsn: usr.bin/spell/spellin.c 4.1

usr/src/usr.bin/spell/spellin.c [new file with mode: 0644]

diff --git a/usr/src/usr.bin/spell/spellin.c b/usr/src/usr.bin/spell/spellin.c
new file mode 100644 (file)
index 0000000..67b6bf7
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef lint
+static char sccsid[] = "@(#)spellin.c  4.1 %G%";
+#endif
+
+#include "spell.h"
+/* add entries to hash table for use by spell
+   preexisting hash table is first argument
+   words to be added are standard input
+   if no hash table is given, create one from scratch
+*/
+
+main(argc,argv)
+char **argv;
+{
+       register i, j;
+       long h;
+       register long *lp;
+       char word[NW];
+       register char *wp;
+
+       if(!prime(argc,argv)) {
+               fprintf(stderr,
+                   "spellin: cannot initialize hash table\n");
+               exit(1);
+       }
+       while (fgets(word, sizeof(word), stdin)) {
+               for (i=0; i<NP; i++) {
+                       for (wp = word, h = 0, lp = pow2[i];
+                                (j = *wp) != '\0'; ++wp, ++lp)
+                               h += j * *lp;
+                       h %= p[i];
+                       set(h);
+               }
+       }
+#ifdef gcos
+       freopen((char *)NULL, "wi", stdout);
+#endif
+       if (fwrite((char *)tab, sizeof(*tab), TABSIZE, stdout) != TABSIZE) {
+               fprintf(stderr,
+                   "spellin: trouble writing hash table\n");
+               exit(1);
+       }
+       return(0);
+}