diff --git a/apps/opencs/model/filter/parser.cpp b/apps/opencs/model/filter/parser.cpp index d363b4849d..6f185d60fa 100644 --- a/apps/opencs/model/filter/parser.cpp +++ b/apps/opencs/model/filter/parser.cpp @@ -17,6 +17,19 @@ #include "textnode.hpp" #include "valuenode.hpp" +namespace +{ + bool isAlpha(char c) + { + return std::isalpha(static_cast(c)); + } + + bool isDigit(char c) + { + return std::isdigit(static_cast(c)); + } +} + namespace CSMFilter { struct Token @@ -103,7 +116,7 @@ CSMFilter::Token CSMFilter::Parser::getStringToken() { char c = mInput[mIndex]; - if (std::isalpha (c) || c==':' || c=='_' || (!string.empty() && std::isdigit (c)) || c=='"' || + if (isAlpha(c) || c==':' || c=='_' || (!string.empty() && isDigit(c)) || c=='"' || (!string.empty() && string[0]=='"')) string += c; else @@ -150,7 +163,7 @@ CSMFilter::Token CSMFilter::Parser::getNumberToken() { char c = mInput[mIndex]; - if (std::isdigit (c)) + if (isDigit(c)) { string += c; hasDigit = true; @@ -225,10 +238,10 @@ CSMFilter::Token CSMFilter::Parser::getNextToken() case '!': ++mIndex; return Token (Token::Type_OneShot); } - if (c=='"' || c=='_' || std::isalpha (c) || c==':') + if (c=='"' || c=='_' || isAlpha(c) || c==':') return getStringToken(); - if (c=='-' || c=='.' || std::isdigit (c)) + if (c=='-' || c=='.' || isDigit(c)) return getNumberToken(); error(); diff --git a/apps/openmw/mwinput/keyboardmanager.cpp b/apps/openmw/mwinput/keyboardmanager.cpp index c5a665e5c6..b121b665e7 100644 --- a/apps/openmw/mwinput/keyboardmanager.cpp +++ b/apps/openmw/mwinput/keyboardmanager.cpp @@ -42,9 +42,9 @@ namespace MWInput bool consumed = SDL_IsTextInputActive() && // Little trick to check if key is printable (!(SDLK_SCANCODE_MASK & arg.keysym.sym) && - (arg.keysym.sym >= 0 && arg.keysym.sym <= 255 && std::isprint(arg.keysym.sym) || // Don't trust isprint for symbols outside the extended ASCII range - (kc == MyGUI::KeyCode::None && arg.keysym.sym > 0xff))); + ((kc == MyGUI::KeyCode::None && arg.keysym.sym > 0xff) || + (arg.keysym.sym >= 0 && arg.keysym.sym <= 255 && std::isprint(arg.keysym.sym)))); if (kc != MyGUI::KeyCode::None && !mBindingsManager->isDetectingBindingState()) { if (MWBase::Environment::get().getWindowManager()->injectKeyPress(kc, 0, arg.repeat)) diff --git a/components/lua/configuration.cpp b/components/lua/configuration.cpp index 4598ed2508..172d958029 100644 --- a/components/lua/configuration.cpp +++ b/components/lua/configuration.cpp @@ -30,6 +30,11 @@ namespace LuaUtil {"POTION", ESM::LuaScriptCfg::sPotion}, {"WEAPON", ESM::LuaScriptCfg::sWeapon}, }; + + bool isSpace(char c) + { + return std::isspace(static_cast(c)); + } } const std::vector ScriptsConfiguration::sEmpty; @@ -101,11 +106,11 @@ namespace LuaUtil if (!line.empty() && line.back() == '\r') line = line.substr(0, line.size() - 1); - while (!line.empty() && std::isspace(line[0])) + while (!line.empty() && isSpace(line[0])) line = line.substr(1); if (line.empty() || line[0] == '#') // Skip empty lines and comments continue; - while (!line.empty() && std::isspace(line.back())) + while (!line.empty() && isSpace(line.back())) line = line.substr(0, line.size() - 1); if (!Misc::StringUtils::ciEndsWith(line, ".lua")) @@ -118,7 +123,7 @@ namespace LuaUtil throw std::runtime_error(Misc::StringUtils::format("No flags found in: %s", std::string(line))); std::string_view flagsStr = line.substr(0, semicolonPos); std::string_view scriptPath = line.substr(semicolonPos + 1); - while (std::isspace(scriptPath[0])) + while (isSpace(scriptPath[0])) scriptPath = scriptPath.substr(1); // Parse flags @@ -126,10 +131,10 @@ namespace LuaUtil size_t flagsPos = 0; while (true) { - while (flagsPos < flagsStr.size() && (std::isspace(flagsStr[flagsPos]) || flagsStr[flagsPos] == ',')) + while (flagsPos < flagsStr.size() && (isSpace(flagsStr[flagsPos]) || flagsStr[flagsPos] == ',')) flagsPos++; size_t startPos = flagsPos; - while (flagsPos < flagsStr.size() && !std::isspace(flagsStr[flagsPos]) && flagsStr[flagsPos] != ',') + while (flagsPos < flagsStr.size() && !isSpace(flagsStr[flagsPos]) && flagsStr[flagsPos] != ',') flagsPos++; if (startPos == flagsPos) break; diff --git a/components/misc/stringops.hpp b/components/misc/stringops.hpp index c8d236a9d0..fe4be00006 100644 --- a/components/misc/stringops.hpp +++ b/components/misc/stringops.hpp @@ -187,7 +187,7 @@ public: const auto notSpace = [](char ch) { // TODO Do we care about multibyte whitespace? - return !std::isspace(ch); + return !std::isspace(static_cast(ch)); }; // left trim s.erase(s.begin(), std::find_if(s.begin(), s.end(), notSpace)); diff --git a/components/settings/parser.cpp b/components/settings/parser.cpp index f2419dfdd6..8d387ab9c7 100644 --- a/components/settings/parser.cpp +++ b/components/settings/parser.cpp @@ -311,7 +311,7 @@ void Settings::SettingsFileParser::saveSettingsFile(const std::string& file, con bool Settings::SettingsFileParser::skipWhiteSpace(size_t& i, std::string& str) { - while (i < str.size() && std::isspace(str[i], std::locale::classic())) + while (i < str.size() && std::isspace(static_cast(str[i]), std::locale::classic())) { ++i; }