aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2011-04-22 09:19:36 +0300
committerArnold D. Robbins <arnold@skeeve.com>2011-04-22 09:19:36 +0300
commit26e0f72a6bb214f1f53326c7b2325715afe43fb6 (patch)
treead7e61cd69a9bdebf41e7d743fef93d8eb025bce /array.c
parentbcb8bd6d6671a3400c4bfe3e34eb4d5d66050f32 (diff)
downloadegawk-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.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/array.c b/array.c
index 15053bb0..3d7ff2fa 100644
--- a/array.c
+++ b/array.c
@@ -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;