diff --git a/RegularExpression.cxx b/RegularExpression.cxx index 5e6f8da50317ec18492955960b7c1e62acb2e725..460cb9434c32f7ccf58c30ad2df09f149b3396a9 100644 --- a/RegularExpression.cxx +++ b/RegularExpression.cxx @@ -367,8 +367,7 @@ bool RegularExpression::compile(const char* exp) // Allocate space. //#ifndef _WIN32 - if (this->program != nullptr) - delete[] this->program; + delete[] this->program; //#endif this->program = new char[comp.regsize]; this->progsize = static_cast<int>(comp.regsize); diff --git a/SystemInformation.cxx b/SystemInformation.cxx index ba9fa67717a862f1969c08845a783d6d86ebadf7..60a467e9cbb2e0fb074b61d6d0e73567466d92ce 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -1366,7 +1366,7 @@ std::string SymbolProperties::GetFileName(const std::string& path) const { std::string file(path); if (!this->ReportPath) { - size_t at = file.rfind("/"); + size_t at = file.rfind('/'); if (at != std::string::npos) { file.erase(0, at + 1); } @@ -3387,8 +3387,8 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile( size_t pos = buffer.find(word, init); if (pos != std::string::npos) { this->CurrentPositionInFile = pos; - pos = buffer.find(":", pos); - size_t pos2 = buffer.find("\n", pos); + pos = buffer.find(':', pos); + size_t pos2 = buffer.find('\n', pos); if (pos != std::string::npos && pos2 != std::string::npos) { // It may happen that the beginning matches, but this is still not the // requested key. @@ -3937,7 +3937,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame, int wholePath) { std::ostringstream oss; - std::string programStack = ""; + std::string programStack; #ifdef KWSYS_SYSTEMINFORMATION_HAS_DBGHELP (void)wholePath; @@ -4688,7 +4688,7 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl( size_t pos = this->SysCtlBuffer.find(word); if (pos != std::string::npos) { pos = this->SysCtlBuffer.find(": ", pos); - size_t pos2 = this->SysCtlBuffer.find("\n", pos); + size_t pos2 = this->SysCtlBuffer.find('\n', pos); if (pos != std::string::npos && pos2 != std::string::npos) { return this->SysCtlBuffer.substr(pos + 2, pos2 - pos - 2); } @@ -5500,13 +5500,13 @@ void SystemInformationImplementation::TrimNewline(std::string& output) { // remove \r std::string::size_type pos = 0; - while ((pos = output.find("\r", pos)) != std::string::npos) { + while ((pos = output.find('\r', pos)) != std::string::npos) { output.erase(pos); } // remove \n pos = 0; - while ((pos = output.find("\n", pos)) != std::string::npos) { + while ((pos = output.find('\n', pos)) != std::string::npos) { output.erase(pos); } } diff --git a/SystemTools.cxx b/SystemTools.cxx index c2fdab561a0a1d3473ede85e27bbb1e1f85e84cf..033c047c0f4efbc3615ea0be19ff5dbea601d1f1 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -2118,7 +2118,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path) ret.erase(pos, 1); } // escape spaces and () in the path - if (ret.find_first_of(" ") != std::string::npos) { + if (ret.find_first_of(' ') != std::string::npos) { std::string result; char lastch = 1; for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) { @@ -3158,7 +3158,7 @@ bool SystemTools::SplitProgramPath(const std::string& in_name, SystemTools::ConvertToUnixSlashes(dir); if (!SystemTools::FileIsDirectory(dir)) { - std::string::size_type slashPos = dir.rfind("/"); + std::string::size_type slashPos = dir.rfind('/'); if (slashPos != std::string::npos) { file = dir.substr(slashPos + 1); dir.resize(slashPos); @@ -3716,7 +3716,7 @@ std::string SystemTools::GetFilenamePath(const std::string& filename) std::string fn = filename; SystemTools::ConvertToUnixSlashes(fn); - std::string::size_type slash_pos = fn.rfind("/"); + std::string::size_type slash_pos = fn.rfind('/'); if (slash_pos == 0) { return "/"; } diff --git a/testCommandLineArguments1.cxx b/testCommandLineArguments1.cxx index cbc30024b51d860efdb5e2108c675fc40c017f06..7e4c707ec680f38b78ca01dc6aa0f4fa2e05bf3f 100644 --- a/testCommandLineArguments1.cxx +++ b/testCommandLineArguments1.cxx @@ -51,9 +51,7 @@ int testCommandLineArguments1(int argc, char* argv[]) std::cout << "Value of N: " << n << std::endl; std::cout << "Value of M: " << m << std::endl; std::cout << "Value of P: " << p << std::endl; - if (m) { - delete[] m; - } + delete[] m; char** newArgv = nullptr; int newArgc = 0;