Explicitly convert int to char during transform on string (equivalent of PR #756)

This commit is contained in:
Phil Nash 2016-11-29 12:04:09 +00:00
parent 79acc0504b
commit 862d13138c

View File

@ -396,9 +396,12 @@ namespace Clara {
inline void convertInto( std::string const& _source, std::string& _dest ) { inline void convertInto( std::string const& _source, std::string& _dest ) {
_dest = _source; _dest = _source;
} }
char toLowerCh(char c) {
return static_cast<char>( ::tolower( c ) );
}
inline void convertInto( std::string const& _source, bool& _dest ) { inline void convertInto( std::string const& _source, bool& _dest ) {
std::string sourceLC = _source; std::string sourceLC = _source;
std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), ::tolower ); std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), toLowerCh );
if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" ) if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" )
_dest = true; _dest = true;
else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" ) else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" )