highlighter: when subtracting char, cast to unsigned

Windows.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2019-01-31 02:03:10 +01:00
parent 4bc6ef0089
commit 1e58a0525e
1 changed files with 2 additions and 2 deletions

View File

@ -166,9 +166,9 @@ static bool is_valid_uint(string_span_t s, bool support_hex, uint64_t min, uint6
if (support_hex && s.len > 2 && s.s[0] == '0' && s.s[1] == 'x') { if (support_hex && s.len > 2 && s.s[0] == '0' && s.s[1] == 'x') {
for (size_t i = 2; i < s.len; ++i) { for (size_t i = 2; i < s.len; ++i) {
if (s.s[i] - '0' < 10) if ((unsigned)s.s[i] - '0' < 10)
val = 16 * val + (s.s[i] - '0'); val = 16 * val + (s.s[i] - '0');
else if ((s.s[i] | 32) - 'a' < 6) else if (((unsigned)s.s[i] | 32) - 'a' < 6)
val = 16 * val + (s.s[i] | 32) - 'a' + 10; val = 16 * val + (s.s[i] | 32) - 'a' + 10;
else else
return false; return false;