optimization for normal masks requires keeping ptr to associated leaf,
[unix-history] / usr / src / usr.bin / spell / spellout.c
CommitLineData
94bed826 1/*-
b8e6ef5e
KB
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
94bed826
KB
4 *
5 * %sccs.include.proprietary.c%
6 */
7
8#ifndef lint
b8e6ef5e
KB
9static char copyright[] =
10"@(#) Copyright (c) 1991, 1993\n\
11 The Regents of the University of California. All rights reserved.\n";
94bed826
KB
12#endif /* not lint */
13
63582369 14#ifndef lint
b8e6ef5e 15static char sccsid[] = "@(#)spellout.c 8.1 (Berkeley) %G%";
94bed826 16#endif /* not lint */
63582369
SL
17
18#include "spell.h"
19
20main(argc, argv)
88618b9c 21int argc;
63582369
SL
22char **argv;
23{
24 register i, j;
25 long h;
26 register long *lp;
27 char word[NW];
28 int dflag = 0;
29 int indict;
30 register char *wp;
31
32 if (argc>1 && argv[1][0]=='-' && argv[1][1]=='d') {
33 dflag = 1;
34 argc--;
35 argv++;
36 }
37 if(argc<=1) {
38 fprintf(stderr,"spellout: arg count\n");
39 exit(1);
40 }
41 if(!prime(argc,argv)) {
42 fprintf(stderr,
43 "spellout: cannot initialize hash table\n");
44 exit(1);
45 }
46 while (fgets(word, sizeof(word), stdin)) {
47 indict = 1;
48 for (i=0; i<NP; i++) {
49 for (wp = word, h = 0, lp = pow2[i];
50 (j = *wp) != '\0'; ++wp, ++lp)
51 h += j * *lp;
52 h %= p[i];
53 if (get(h)==0) {
54 indict = 0;
55 break;
56 }
57 }
58 if (dflag == indict)
59 fputs(word, stdout);
60 }
61}