Mercurial > irccd
changeset 349:56475d6c1c30
Irccd: fix util::isBoolean
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 13 Nov 2016 20:59:45 +0100 |
parents | 24b1709093e7 |
children | 287e9ede5eef |
files | libcommon/irccd/util.cpp libcommon/irccd/util.hpp |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libcommon/irccd/util.cpp Sun Nov 13 14:16:58 2016 +0100 +++ b/libcommon/irccd/util.cpp Sun Nov 13 20:59:45 2016 +0100 @@ -374,8 +374,12 @@ return MessagePair(result, ((iscommand) ? MessageType::Command : MessageType::Message)); } -bool isBoolean(const std::string &value) noexcept +bool isBoolean(std::string value) noexcept { + std::transform(value.begin(), value.end(), value.begin(), [] (auto c) { + return toupper(c); + }); + return value == "1" || value == "YES" || value == "TRUE" || value == "ON"; }
--- a/libcommon/irccd/util.hpp Sun Nov 13 14:16:58 2016 +0100 +++ b/libcommon/irccd/util.hpp Sun Nov 13 20:59:45 2016 +0100 @@ -253,7 +253,7 @@ * \return true if is boolean * \note this function is case-insensitive */ -IRCCD_EXPORT bool isBoolean(const std::string &value) noexcept; +IRCCD_EXPORT bool isBoolean(std::string value) noexcept; /** * Check if the string is an integer.