]> git.tdb.fi Git - libs/core.git/blobdiff - source/lexicalcast.cpp
Add utility functions to check the contents of a string
[libs/core.git] / source / lexicalcast.cpp
index 687a37b4e3ebb85250e699d30c54da9f0e66b7ed..cdd55780b5f612ee86cce7db6beee8c64d80502f 100644 (file)
@@ -211,10 +211,14 @@ string bool_to_str(bool b, const Fmt &f)
 
 bool str_to_bool(const string &s)
 {
+       if(s.empty())
+               throw LexicalError("Empty input in boolean conversion");
+
        if(s=="1" || s=="true" || s=="yes" || s=="on")
                return true;
        else if(s=="0" || s=="false" || s=="no" || s=="off")
-               return true;
+               return false;
+
        throw LexicalError("Invalid input in boolean conversion");
 }