ref: be48e0969a3531f1b4bbd162dde599ca430d599f
parent: 4ffe395a66f3b0d78ec53295a81536ed7f094a00
author: Roberto E. Vargas Caballero <[email protected]>
date: Sun Feb 19 14:30:17 EST 2017
[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)
--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -51,14 +51,13 @@
#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;