From 945901ad282138760ece6caf686a1380423bb6ce Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 2 Feb 2016 11:32:20 +0100 Subject: [PATCH] Changed: Support more values for fromString with a boolean --- code/nel/include/nel/misc/string_common.h | 29 ++++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/code/nel/include/nel/misc/string_common.h b/code/nel/include/nel/misc/string_common.h index e6d08bdeb..b8a12ad77 100644 --- a/code/nel/include/nel/misc/string_common.h +++ b/code/nel/include/nel/misc/string_common.h @@ -246,27 +246,38 @@ inline bool fromString(const std::string &str, bool &val) { if (str.length() == 1) { - if (str[0] == '1') + const char c = str[0]; + + switch(c) { + case '1': + case 't': + case 'T': + case 'y': + case 'Y': val = true; - } - else if (str[0] == '0') - { + break; + + case '0': + case 'f': + case 'F': + case 'n': + case 'N': val = false; - } - else - { + break; + + default: val = false; return false; } } else { - if (str == "true") + if (str == "true" || str == "yes") { val = true; } - else if (str == "false") + else if (str == "false" || str == "no") { val = false; }