From 9eb39bfd86ef941598627485897b5eeac9112d54 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 20 Jan 2021 14:50:29 +0300 Subject: [PATCH] settings: parse bool as string --- code/espurna/settings.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/code/espurna/settings.cpp b/code/espurna/settings.cpp index 08eee12d..e56fd7d2 100644 --- a/code/espurna/settings.cpp +++ b/code/espurna/settings.cpp @@ -87,7 +87,23 @@ long convert(const String& value) { template <> bool convert(const String& value) { - return convert(value) == 1; + if (value.length()) { + if ((value == "0") + || (value == "n") + || (value == "no") + || (value == "false") + || (value == "off")) { + return false; + } + + return (value == "1") + || (value == "y") + || (value == "yes") + || (value == "true") + || (value == "on"); + } + + return false; } template <>