hecl/SystemChar: Cast to unsigned char before calling tolower/toupper

Performed for the same reasons outlined within
b32f16b519eafacb9de4852855486270f73d5e2e (avoiding undefined behavior).
This commit is contained in:
Lioncash 2019-08-14 23:55:24 -04:00
parent b63d848846
commit 58e0c7eaa7
1 changed files with 8 additions and 2 deletions

View File

@ -40,8 +40,14 @@ typedef char SystemChar;
static inline size_t StrLen(const SystemChar* str) { return strlen(str); }
typedef std::string SystemString;
typedef std::string_view SystemStringView;
static inline void ToLower(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), tolower); }
static inline void ToUpper(SystemString& str) { std::transform(str.begin(), str.end(), str.begin(), toupper); }
static inline void ToLower(SystemString& str) {
std::transform(str.begin(), str.end(), str.begin(),
[](SystemChar c) { return std::tolower(static_cast<unsigned char>(c)); });
}
static inline void ToUpper(SystemString& str) {
std::transform(str.begin(), str.end(), str.begin(),
[](SystemChar c) { return std::toupper(static_cast<unsigned char>(c)); });
}
#ifndef _SYS_STR
#define _SYS_STR(val) val
#endif