2 static char rcsid[] = "$Id: lookup.c,v 2.7 1994/06/24 10:40:10 ceriel Exp $";
13 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
14 * See the copyright notice in the ACK home directory, in the file "Copyright".
16 * Author: Hans van Staveren
19 extern char *strncpy();
21 unsigned hash(string) char *string; {
23 register unsigned i,sum;
25 for (sum=i=0,p=string;*p;i += 3)
26 sum ^= (*p++)<<(i&07);
30 sym_p symlookup(name,status,flags) char *name; int status,flags; {
31 register sym_p *spp,sp;
33 static short genfrag = 32767;
35 spp = &symhash[hash(name)%NSYMHASH];
36 while (*spp != (sym_p) 0)
37 if (strncmp((*spp)->s_name,name,IDL)==0) {
39 if ((sp->s_flags^flags)&SYMPRO)
40 error("%s is both proc and datalabel",name);
41 if (status == DEFINING) {
42 if (sp->s_flags&SYMDEF)
43 error("redefined symbol %s",name);
44 sp->s_flags |= SYMDEF;
48 spp = &(*spp)->s_next;
51 * symbol not found, enter in table
59 *spp = sp = newsym(i);
60 strncpy(sp->s_name,name,i);
62 if (status == DEFINING)
63 sp->s_flags |= SYMDEF;
64 sp->s_frag = genfrag--;
68 num_p numlookup(number) unsigned number; {
69 register num_p *npp, np;
71 npp = &curpro.numhash[number%NNUMHASH];
72 while (*npp != (num_p) 0)
73 if ((*npp)->n_number == number)
76 npp = &(*npp)->n_next;
79 * local label not found, enter in tabel
83 np->n_number = number;