8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / refer / mkey3.c
blob93f0c7673fe96100af45b3c147207b74bef9c269
1 /*
2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
9 /*
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 #include <stdio.h>
18 #define COMNUM 500
19 #define COMTSIZE 997
21 char *comname = "/usr/lib/refer/eign";
22 static int cgate = 0;
23 extern char *comname;
24 int comcount = 100;
25 static char cbuf[COMNUM*9];
26 static char *cwds[COMTSIZE];
27 static char *cbp;
29 extern int hash();
30 extern char *trimnl();
32 static void cominit(void);
33 static int c_look(char *, int);
35 int
36 common(char *s)
38 if (cgate == 0) cominit();
39 return (c_look(s, 1));
42 static void
43 cominit(void)
45 int i;
46 FILE *f;
47 cgate = 1;
48 f = fopen(comname, "r");
49 if (f == NULL)
50 return;
51 cbp = cbuf;
52 for (i = 0; i < comcount; i++) {
53 if (fgets(cbp, 15, f) == NULL)
54 break;
55 trimnl(cbp);
56 c_look(cbp, 0);
57 while (*cbp++)
60 fclose(f);
63 static int
64 c_look(char *s, int fl)
66 int h;
67 h = hash(s) % (COMTSIZE);
68 while (cwds[h] != 0) {
69 if (strcmp(s, cwds[h]) == 0)
70 return (1);
71 h = (h+1) % (COMTSIZE);
73 if (fl == 0)
74 cwds[h] = s;
75 return (0);