scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 14fdb4eb3b67d5074552c53f695980f837cfd5d9
parent 401f1f8b893bfcb71ae24e75f8126c2f40558ff9
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Sun, 19 Feb 2017 19:30:17 +0100

[cc1] Change the hash algorithm used

This code pretended to be an implementation of djb2, but it has
an error that converted it in an implementation of lose lose
(http://www.cse.yorku.ca/~oz/hash.html)

Diffstat:
Mcc1/symbol.c | 5++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -51,14 +51,13 @@ dumpstab(Symbol **tbl, char *msg) #endif static Symbol ** -hash(const char *s, int ns) +hash(char *s, int ns) { unsigned c, h; Symbol **tab; - for (h = 0; c = *s; ++s) - h ^= 33 * c; + h = h*33 ^ c; h &= NR_SYM_HASH-1; tab = (ns == NS_CPP) ? htabcpp : htab;