summaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-03-05 07:44:34 -0800
committerKaz Kylheku <kaz@kylheku.com>2021-03-05 07:44:34 -0800
commitbc7859d87f7126814532a012c5ee0c7ce19e47ab (patch)
treea2380b2e2099c9b9a42320fe9fc8cadcbb8e19d1 /hash.c
parent3c7cbac43de030255055acf329d075f72b837e62 (diff)
downloadtxr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.tar.gz
txr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.tar.bz2
txr-bc7859d87f7126814532a012c5ee0c7ce19e47ab.zip
hashing: bug: hash-equal zero: floats and bignums.
hash.c (equal_hash): Do not multiply by the seed if it is zero; substitute 1. Otherwise under the default seed of zero, the hash becomes zero.
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/hash.c b/hash.c
index 1cbc8285..2cdbdae2 100644
--- a/hash.c
+++ b/hash.c
@@ -257,9 +257,9 @@ ucnum equal_hash(val obj, int *count, ucnum seed)
lazy_str_force_upto(obj, num(*count - 1));
return equal_hash(obj->ls.prefix, count, seed);
case BGNUM:
- return mp_hash(mp(obj)) * seed;
+ return mp_hash(mp(obj)) * if3(seed, seed, 1);
case FLNUM:
- return hash_double(obj->fl.n) * seed;
+ return hash_double(obj->fl.n) * if3(seed, seed, 1);
case COBJ:
case CPTR:
if (obj->co.ops->equalsub) {