Skip to content

Commit c9e2b56

Browse files
committed
Make code easier to debug
1 parent 35b94a1 commit c9e2b56

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

cli/cppcheckexecutor.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -975,8 +975,10 @@ void CppCheckExecutor::reportErr(const std::string &errmsg)
975975
_errorList.insert(errmsg);
976976
if (errorOutput)
977977
*errorOutput << errmsg << std::endl;
978-
else
979-
std::cerr << ansiToOEM(errmsg, _settings ? !_settings->xml : true) << std::endl;
978+
else {
979+
const bool doConvert = (_settings == nullptr) ? true : !_settings->xml;
980+
std::cerr << ansiToOEM(errmsg, doConvert) << std::endl;
981+
}
980982
}
981983

982984
void CppCheckExecutor::reportOut(const std::string &outmsg)
@@ -1016,9 +1018,9 @@ void CppCheckExecutor::reportStatus(std::size_t fileindex, std::size_t filecount
10161018
{
10171019
if (filecount > 1) {
10181020
std::ostringstream oss;
1021+
const long percentDone = (sizetotal > 0) ? static_cast<long>(static_cast<long double>(sizedone) / sizetotal * 100) : 0;
10191022
oss << fileindex << '/' << filecount
1020-
<< " files checked " <<
1021-
(sizetotal > 0 ? static_cast<long>(static_cast<long double>(sizedone) / sizetotal*100) : 0)
1023+
<< " files checked " << percentDone
10221024
<< "% done";
10231025
std::cout << oss.str() << std::endl;
10241026
}

0 commit comments

Comments
 (0)