|
|
researchv10 Norman
# include "stdio.h"
# include "assert.h"
char *comname = "/usr/lib/eign";
static int cgate = 0;
extern char *comname;
# define COMNUM 500
# define COMTSIZE 997
int comcount = 400;
static char cbuf[COMNUM*9];
static char *cwds[COMTSIZE];
static char *cbp;
common (s)
char *s;
{
if (cgate==0) cominit();
return (c_look(s, 1));
}
cominit()
{
int i;
FILE *f;
cgate=1;
f = fopen(comname, "r");
if (f==NULL) return;
cbp=cbuf;
for(i=0; i<comcount; i++)
{
if (fgets(cbp, 15, f)==NULL)
break;
trimnl(cbp);
c_look (cbp, 0);
while (*cbp++);
}
fclose(f);
}
c_look (s, fl)
char *s;
{
int h;
h = hash(s) % (COMTSIZE);
while (cwds[h] != 0)
{
if (strcmp(s, cwds[h])==0)
return(1);
h = (h+1) % (COMTSIZE);
}
if (fl==0)
cwds[h] = s;
return(0);
}
hash (s)
char *s;
{
int c, n;
for(n=0; c= *s; s++)
n += (c*n+ c << (n%4));
return(n>0 ? n : -n);
}
char *
svc(s)
char *s;
{
char *p, *calloc();
p = calloc(strlen(s)+1,1);
assert(p!=0);
strcpy(p,s);
return(p);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.