Codechange: replace strncasecmp with case ignoring variant of StrStarts/EndsWith

This commit is contained in:
Rubidium
2023-04-27 13:21:08 +02:00
committed by rubidium42
parent 86786a7af6
commit 4dd5f994be
10 changed files with 410 additions and 41 deletions

View File

@@ -99,8 +99,9 @@ static uint16 ParseCode(const char *start, const char *end)
assert(start <= end);
while (start < end && *start == ' ') start++;
while (end > start && *end == ' ') end--;
std::string_view str{start, (size_t)(start - end)};
for (uint i = 0; i < lengthof(_keycode_to_name); i++) {
if (strlen(_keycode_to_name[i].name) == (size_t)(end - start) && strncasecmp(start, _keycode_to_name[i].name, end - start) == 0) {
if (StrEqualsIgnoreCase(str, _keycode_to_name[i].name)) {
return _keycode_to_name[i].keycode;
}
}