🚨 fixed warnings

This commit is contained in:
Niels Lohmann 2019-03-15 15:55:52 +01:00
parent 8d6c033f80
commit b02ee16721
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
5 changed files with 100 additions and 100 deletions

View file

@ -149,22 +149,22 @@ class lexer
assert(current == 'u');
int codepoint = 0;
const auto factors = { 12, 8, 4, 0 };
const auto factors = { 12u, 8u, 4u, 0u };
for (const auto factor : factors)
{
get();
if (current >= '0' and current <= '9')
{
codepoint += ((current - 0x30) << factor);
codepoint += ((static_cast<unsigned int>(current) - 0x30u) << factor);
}
else if (current >= 'A' and current <= 'F')
{
codepoint += ((current - 0x37) << factor);
codepoint += ((static_cast<unsigned int>(current) - 0x37u) << factor);
}
else if (current >= 'a' and current <= 'f')
{
codepoint += ((current - 0x57) << factor);
codepoint += ((static_cast<unsigned int>(current) - 0x57u) << factor);
}
else
{
@ -324,13 +324,13 @@ class lexer
// overwrite codepoint
codepoint =
// high surrogate occupies the most significant 22 bits
(codepoint1 << 10)
(static_cast<unsigned int>(codepoint1) << 10u)
// low surrogate occupies the least significant 15 bits
+ codepoint2
+ static_cast<unsigned int>(codepoint2)
// there is still the 0xD800, 0xDC00 and 0x10000 noise
// in the result so we have to subtract with:
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
- 0x35FDC00;
- 0x35FDC00u;
}
else
{
@ -365,23 +365,23 @@ class lexer
else if (codepoint <= 0x7FF)
{
// 2-byte characters: 110xxxxx 10xxxxxx
add(0xC0 | (codepoint >> 6));
add(0x80 | (codepoint & 0x3F));
add(0xC0u | (static_cast<unsigned int>(codepoint) >> 6u));
add(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu));
}
else if (codepoint <= 0xFFFF)
{
// 3-byte characters: 1110xxxx 10xxxxxx 10xxxxxx
add(0xE0 | (codepoint >> 12));
add(0x80 | ((codepoint >> 6) & 0x3F));
add(0x80 | (codepoint & 0x3F));
add(0xE0u | (static_cast<unsigned int>(codepoint) >> 12u));
add(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu));
add(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu));
}
else
{
// 4-byte characters: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
add(0xF0 | (codepoint >> 18));
add(0x80 | ((codepoint >> 12) & 0x3F));
add(0x80 | ((codepoint >> 6) & 0x3F));
add(0x80 | (codepoint & 0x3F));
add(0xF0u | (static_cast<unsigned int>(codepoint) >> 18u));
add(0x80u | ((static_cast<unsigned int>(codepoint) >> 12u) & 0x3Fu));
add(0x80u | ((static_cast<unsigned int>(codepoint) >> 6u) & 0x3Fu));
add(0x80u | (static_cast<unsigned int>(codepoint) & 0x3Fu));
}
break;
@ -1298,7 +1298,7 @@ scan_number_done:
if (JSON_LIKELY(current != std::char_traits<char>::eof()))
{
assert(token_string.size() != 0);
assert(not token_string.empty());
token_string.pop_back();
}
}