X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flexicalcast.cpp;h=9ba642f2ae48bebe826c226ef98b8604e4c49114;hb=a0a5c796a6ec11a13c49912672a82bf1857bbc71;hp=687a37b4e3ebb85250e699d30c54da9f0e66b7ed;hpb=f5aa787e1a715867a8024816ccd58e9a4c7e23a4;p=libs%2Fcore.git diff --git a/source/lexicalcast.cpp b/source/lexicalcast.cpp index 687a37b..9ba642f 100644 --- a/source/lexicalcast.cpp +++ b/source/lexicalcast.cpp @@ -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"); } @@ -301,7 +305,7 @@ string flt_to_str(T v, const Fmt &f) } // Apply rounding - w+=5.0l/pow(10.0l, digits); + w+=5.0l/pow(10.0l, static_cast(digits)); if(w>10) { // Rounding bumped us to the next exponent, deal with it