=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/m4/look.c,v retrieving revision 1.5 retrieving revision 1.6 diff -c -r1.5 -r1.6 *** src/usr.bin/m4/look.c 1999/11/17 15:34:13 1.5 --- src/usr.bin/m4/look.c 1999/11/20 17:48:59 1.6 *************** *** 1,4 **** ! /* $OpenBSD: look.c,v 1.5 1999/11/17 15:34:13 espie Exp $ */ /* * Copyright (c) 1989, 1993 --- 1,4 ---- ! /* $OpenBSD: look.c,v 1.6 1999/11/20 17:48:59 espie Exp $ */ /* * Copyright (c) 1989, 1993 *************** *** 57,70 **** static void freent __P((ndptr)); ! int hash(name) const char *name; { ! unsigned long h = 0; while (*name) h = (h << 5) + h + *name++; ! return (h % HASHSIZE); } /* --- 57,70 ---- static void freent __P((ndptr)); ! unsigned hash(name) const char *name; { ! unsigned h = 0; while (*name) h = (h << 5) + h + *name++; ! return (h); } /* *************** *** 75,83 **** const char *name; { ndptr p; ! for (p = hashtab[hash(name)]; p != nil; p = p->nxtptr) ! if (STREQ(name, p->name)) break; return (p); } --- 75,85 ---- const char *name; { ndptr p; + unsigned h; ! h = hash(name); ! for (p = hashtab[h % HASHSIZE]; p != nil; p = p->nxtptr) ! if (h == p->hv && STREQ(name, p->name)) break; return (p); } *************** *** 90,103 **** addent(name) const char *name; { ! int h; ndptr p; h = hash(name); p = (ndptr) xalloc(sizeof(struct ndblock)); ! p->nxtptr = hashtab[h]; ! hashtab[h] = p; p->name = xstrdup(name); return p; } --- 92,106 ---- addent(name) const char *name; { ! unsigned h; ndptr p; h = hash(name); p = (ndptr) xalloc(sizeof(struct ndblock)); ! p->nxtptr = hashtab[h % HASHSIZE]; ! hashtab[h % HASHSIZE] = p; p->name = xstrdup(name); + p->hv = h; return p; } *************** *** 125,138 **** ndptr xp, tp, mp; h = hash(name); ! mp = hashtab[h]; tp = nil; while (mp != nil) { ! if (STREQ(mp->name, name)) { mp = mp->nxtptr; if (tp == nil) { ! freent(hashtab[h]); ! hashtab[h] = mp; } else { xp = tp->nxtptr; --- 128,141 ---- ndptr xp, tp, mp; h = hash(name); ! mp = hashtab[h % HASHSIZE]; tp = nil; while (mp != nil) { ! if (mp->hv == h && STREQ(mp->name, name)) { mp = mp->nxtptr; if (tp == nil) { ! freent(hashtab[h % HASHSIZE]); ! hashtab[h % HASHSIZE] = mp; } else { xp = tp->nxtptr;