scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit a83473384064ef893eb720c97f3c1cce53d17729
parent 4a7755c02dd49d9c9fb0a49fc224764e777cbb83
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 21 Sep 2023 09:09:42 +0200

libc: Make genhash() a proper djb2 function

The function genhash() was almost a djb2 hashing function but it had
some small differences that this commit is changing to follow the last
version of djb2 from Bernstein.

Diffstat:
Msrc/libscc/genhash.c | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/libscc/genhash.c b/src/libscc/genhash.c @@ -1,10 +1,10 @@ unsigned genhash(char *name) { - unsigned h; - char c; + int c; + unsigned h = 5381; - for (h = 0; c = *name; ++name) + while (c = *name++) h = h*33 ^ c; return h;