summaryrefslogtreecommitdiff
path: root/src/configparser.cpp
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2021-03-13 02:33:05 +0000
committerSadie Powell <sadie@witchery.services>2021-03-14 00:23:56 +0000
commite109aba3acbc32cecfd57477d47c2b2fc88c6752 (patch)
treea88f7d70d53b7d390536932436c343af941ce5d3 /src/configparser.cpp
parentb378b5087b41f72a1624ebb58990180e0b0140aa (diff)
Treat an empty bool/duration/int/uint config field as undefined.
Diffstat (limited to 'src/configparser.cpp')
-rw-r--r--src/configparser.cpp8
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")