From a9a6411051e2c39ff17c3bf6e7b46c658505da4f Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Wed, 16 Oct 2024 11:39:59 +0100 Subject: Allow ConfigTag::getCharacter to return NUL for an empty field. --- src/configparser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/configparser.cpp') diff --git a/src/configparser.cpp b/src/configparser.cpp index 8cdd1f7f5..457840b71 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -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]; } -- cgit v1.3.1-10-gc9f91