Commit 67bd88cf authored by neverlord's avatar neverlord

overflow bugfix

parent a5ad33b9
......@@ -40,27 +40,29 @@ constexpr char encoding_table[] =
/* 0.. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 1.. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 2.. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 3.. */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 0, 0, 0, 0,
/* 4.. */ 0, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
/* 5.. */ 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 0, 0, 0, 0, 38,
/* 6.. */ 0, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
/* 7.. */ 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 0, 0, 0, 0, 0
/* 3.. */ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0, 0, 0, 0, 0, 0,
/* 4.. */ 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
/* 5.. */ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 0, 0, 0, 0, 37,
/* 6.. */ 0, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
/* 7.. */ 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 0, 0, 0, 0, 0
};
// decodes 6bit characters to ASCII
constexpr char decoding_table[] = " 0123456789:"
constexpr char decoding_table[] = " 0123456789"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ_"
"abcdefghijklmnopqrstuvwxyz";
inline constexpr std::uint64_t next_interim(std::uint64_t tmp, size_t char_code)
constexpr std::uint64_t next_interim(std::uint64_t current, size_t char_code)
{
return (tmp << 6) | encoding_table[char_code];
return (current << 6) | encoding_table[(char_code <= 0x7F) ? char_code : 0];
}
constexpr std::uint64_t atom_val(char const* str, std::uint64_t interim = 0)
constexpr std::uint64_t atom_val(char const* cstr, std::uint64_t interim = 0)
{
return (*str <= 0) ? interim
: atom_val(str + 1, next_interim(interim, *str));
return (*cstr == '\0') ? interim
: atom_val(cstr + 1,
next_interim(interim,
static_cast<size_t>(*cstr)));
}
} } } // namespace cppa::detail::<anonymous>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment