commit 14fdb4eb3b67d5074552c53f695980f837cfd5d9
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sun Feb 19 19:30:17 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sun Feb 19 19:37:50 2017 +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)
diff --git a/cc1/symbol.c b/cc1/symbol.c
index 0053ba3..bdd26d6 100644
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
_AT_@ -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;
Received on Sun Feb 19 2017 - 19:37:57 CET