hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 0d10b8722881d8de1bd8e05888d5b3c84436c147
parent fe79d556a7dfe92b6481c866e16886ef71237d68
Author: Alexey Yerin <yyp@disroot.org>
Date:   Mon, 25 Apr 2022 21:47:37 +0300

hash::fnv: use correct vtables for fnv{32,64}a()

fnvN and fnvNa have different hashing constants and thus produce
different results. This caused cmd/haretype to not work.

Signed-off-by: Alexey Yerin <yyp@disroot.org>

Diffstat:
Mhash/fnv/fnv.ha | 14++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/hash/fnv/fnv.ha b/hash/fnv/fnv.ha @@ -57,11 +57,16 @@ export fn fnv32() state32 = state32 { ... }; +const fnv32a_vtable: io::vtable = io::vtable { + writer = &fnv32a_write, + ... +}; + // Creates a [[hash::hash]] which computes the FNV-1a 32-bit hash function. This // hash does not allocate any state, so you do not need to call [[hash::close]] // when you're done with it. export fn fnv32a() state32 = state32 { - stream = &fnv32_vtable, + stream = &fnv32a_vtable, sum = &fnv32_sum, reset = &fnv32_reset, sz = 4, @@ -88,11 +93,16 @@ export fn fnv64() state64 = state64 { ... }; +const fnv64a_vtable: io::vtable = io::vtable { + writer = &fnv64a_write, + ... +}; + // Creates a [[hash::hash]] which computes the FNV-1a 64-bit hash function. This // hash does not allocate any state, so you do not need to call [[hash::close]] // when you're done with it. export fn fnv64a() state64 = state64 { - stream = &fnv64_vtable, + stream = &fnv64a_vtable, sum = &fnv64_sum, reset = &fnv64_reset, sz = 8,