modified hash function to deliver same value on 2 byte and 4 byte machines

This commit is contained in:
ceriel 1991-01-31 15:17:54 +00:00
parent ae5dded36f
commit 2c3dcb0547

View file

@ -26,7 +26,7 @@ struct symbol {
ind_t sy_next; ind_t sy_next;
}; };
#define NHASH 256 /* Size of hash table. Should be even. */ #define NHASH 307 /* Size of hash table. Must be odd. */
static ind_t hashtable[NHASH]; static ind_t hashtable[NHASH];
@ -134,12 +134,12 @@ int
hash(p) hash(p)
register char *p; register char *p;
{ {
register unsigned int h = 0; register unsigned short h = 0;
register int c; register int c;
while (c = *p++) { while (c = *p++) {
h <<= 2; h <<= 2;
h += c; h += c;
} }
return h & (NHASH - 1); return h % NHASH;
} }