diff options
Diffstat (limited to 'common/config-manager.cpp')
-rw-r--r-- | common/config-manager.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 03fcb20abf..a9d8c89035 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -31,7 +31,7 @@ DECLARE_SINGLETON(Common::ConfigManager); static bool isValidDomainName(const Common::String &domName) { const char *p = domName.c_str(); - while (*p && (isalnum(*p) || *p == '-' || *p == '_')) + while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_')) p++; return *p == 0; } @@ -187,7 +187,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) { // Get the domain name, and check whether it's valid (that // is, verify that it only consists of alphanumerics, // dashes and underscores). - while (*p && (isalnum(*p) || *p == '-' || *p == '_')) + while (*p && (isalnum(static_cast<unsigned char>(*p)) || *p == '-' || *p == '_')) p++; if (*p == '\0') @@ -205,7 +205,7 @@ void ConfigManager::loadFromStream(SeekableReadStream &stream) { // Skip leading whitespaces const char *t = line.c_str(); - while (isspace(*t)) + while (isspace(static_cast<unsigned char>(*t))) t++; // Skip empty lines / lines with only whitespace @@ -491,11 +491,9 @@ int ConfigManager::getInt(const String &key, const String &domName) const { bool ConfigManager::getBool(const String &key, const String &domName) const { String value(get(key, domName)); - - if ((value == "true") || (value == "yes") || (value == "1")) - return true; - if ((value == "false") || (value == "no") || (value == "0")) - return false; + bool val; + if (Common::parseBool(value, val)) + return val; error("ConfigManager::getBool(%s,%s): '%s' is not a valid bool", key.c_str(), domName.c_str(), value.c_str()); |