fix our fletcher32 checksumming: we consider only letters, but the short locations was based on the total number of characters in the string

This commit is contained in:
Tim Felgentreff 2021-07-13 18:11:56 +02:00
parent e2ec6a87f5
commit f26a10e2db

View file

@ -168,10 +168,12 @@ uint32_t fletcher32(const std::string &content)
{
uint16_t *alphas = new uint16_t[content.size() / 2];
size_t shorts = 0;
size_t consideredChars = 0;
for (size_t i = 0; i < content.size(); i++) {
uint16_t c = content[i];
if (c >= 'A' && c <= 'z') {
if ((i % 2) == 0) {
consideredChars++;
if ((consideredChars % 2) == 0) {
alphas[shorts] = c << 8;
} else {
alphas[shorts] = alphas[shorts] || c;