mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-08 17:19:01 -05:00
Allow ConfigTag::getCharacter to return NUL for an empty field.
This commit is contained in:
parent
4ad5257918
commit
a9a6411051
@ -129,7 +129,7 @@ public:
|
||||
/** Get the value of an option, using def if it does not exist */
|
||||
bool getBool(const std::string& key, bool def = false) const;
|
||||
/** Get the value of an option, using def if it does not exist */
|
||||
unsigned char getCharacter(const std::string& key, unsigned char def = '\0') const;
|
||||
unsigned char getCharacter(const std::string& key, unsigned char def = '\0', bool emptynul = false) const;
|
||||
|
||||
/** Get the value in seconds of a duration that is in the user-friendly "1h2m3s" format,
|
||||
* using a default value if it does not exist or is out of bounds.
|
||||
|
@ -732,12 +732,15 @@ bool ConfigTag::getBool(const std::string& key, bool def) const
|
||||
return def;
|
||||
}
|
||||
|
||||
unsigned char ConfigTag::getCharacter(const std::string& key, unsigned char def) const
|
||||
unsigned char ConfigTag::getCharacter(const std::string& key, unsigned char def, bool emptynul) const
|
||||
{
|
||||
std::string result;
|
||||
if (!readString(key, result) || result.size() != 1)
|
||||
if (!readString(key, result))
|
||||
return def;
|
||||
|
||||
if (result.size() != 1)
|
||||
return result.empty() && emptynul ? 0 : def;
|
||||
|
||||
return result[0];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user