diff options
| author | 2021-03-13 02:33:05 +0000 | |
|---|---|---|
| committer | 2021-03-14 00:23:56 +0000 | |
| commit | e109aba3acbc32cecfd57477d47c2b2fc88c6752 (patch) | |
| tree | a88f7d70d53b7d390536932436c343af941ce5d3 /src | |
| parent | Allow passing --prefix with --system. (diff) | |
Treat an empty bool/duration/int/uint config field as undefined.
Diffstat (limited to 'src')
| -rw-r--r-- | src/configparser.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index b68c52cbb..556442627 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -628,7 +628,7 @@ namespace long ConfigTag::getInt(const std::string &key, long def, long min, long max) { std::string result; - if(!readString(key, result)) + if(!readString(key, result) || result.empty()) return def; const char* res_cstr = result.c_str(); @@ -645,7 +645,7 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max) unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string result; - if (!readString(key, result)) + if (!readString(key, result) || result.empty()) return def; const char* res_cstr = result.c_str(); @@ -662,7 +662,7 @@ unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsi unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string duration; - if (!readString(key, duration)) + if (!readString(key, duration) || duration.empty()) return def; unsigned long ret; @@ -691,7 +691,7 @@ double ConfigTag::getFloat(const std::string& key, double def, double min, doubl bool ConfigTag::getBool(const std::string &key, bool def) { std::string result; - if(!readString(key, result)) + if(!readString(key, result) || result.empty()) return def; if (stdalgo::string::equalsci(result, "yes") || stdalgo::string::equalsci(result, "true") || stdalgo::string::equalsci(result, "on") || result == "1") |
