Skip to content

Commit a53822e

Browse files
lzaoralkdudka
authored andcommitted
hash-util: make the code work with boost-1.86
... where `TEng::digest_type` expands to an array of chars rather than an array of ints. This caused each byte in the resulting hash string to be prepended by 3 zero bytes, which was detected by the CI on macOS: ``` --- /Users/runner/work/csdiff/csdiff/tests/csgrep/0036-csgrep-json-stdout.txt 2024-08-26 16:59:02 +++ - 2024-08-26 17:00:30 @@ -4,7 +4,7 @@ "checker": "SHELLCHECK_WARNING", "language": "shell", "tool": "shellcheck", - "hash_v1": "b6311c1fdc52c47d4279cd6650af36e6f8299960", + "hash_v1": "000000b6000000310000001c0000001f000000dc00000052000000c40000007d0000004200000079000000cd0000006600000050000000af00000036000000e6000000f8000000290000009900000060", "key_event_idx": 0, "events": [ { ```
1 parent 6cd12b1 commit a53822e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/lib/hash-util.hh

+6-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ std::string hexHashStr(const TSrc &src)
3131
TEng eng;
3232
eng.process_bytes(src.data(), src.size());
3333

34-
// export the hash as an array of unsigned int
35-
typename TEng::digest_type dst;
34+
// export the hash as an array
35+
using TDst = typename TEng::digest_type;
36+
TDst dst;
3637
eng.get_digest(dst);
3738

38-
// convert the hash to a vector of unsigned int
39+
// convert the hash to a vector
3940
static const size_t len = sizeof(dst) / sizeof(dst[0]);
40-
const std::vector<unsigned> hash(dst, dst + len);
41+
using TElem = typename std::remove_extent<TDst>::type;
42+
const std::vector<TElem> hash(dst, dst + len);
4143

4244
// convert the hash to a hex string
4345
std::string result;

0 commit comments

Comments
 (0)