diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-04-22 09:19:36 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-04-22 09:19:36 +0300 |
commit | 26e0f72a6bb214f1f53326c7b2325715afe43fb6 (patch) | |
tree | ad7e61cd69a9bdebf41e7d743fef93d8eb025bce /array.c | |
parent | bcb8bd6d6671a3400c4bfe3e34eb4d5d66050f32 (diff) | |
download | egawk-26e0f72a6bb214f1f53326c7b2325715afe43fb6.tar.gz egawk-26e0f72a6bb214f1f53326c7b2325715afe43fb6.tar.bz2 egawk-26e0f72a6bb214f1f53326c7b2325715afe43fb6.zip |
Add 32/64 bit consistency in hashing.
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -427,9 +427,15 @@ awk_hash(const char *s, size_t len, unsigned long hsize, size_t *code) * Even more speed: * #define HASHC h = *s++ + 65599 * h * Because 65599 = pow(2, 6) + pow(2, 16) - 1 we multiply by shifts + * + * 4/2011: Force the results to 32 bits, to get the same + * result on both 32- and 64-bit systems. This may be a + * bad idea. */ #define HASHC htmp = (h << 6); \ - h = *s++ + htmp + (htmp << 10) - h + h = *s++ + htmp + (htmp << 10) - h ; \ + htmp &= 0xFFFFFFFF; \ + h &= 0xFFFFFFFF; unsigned long htmp; |