Remove redundant c_str() calls

This commit is contained in:
Daniel Pfeifer
2016-10-30 18:34:06 +01:00
parent c58c739da7
commit 602b78aa79
14 changed files with 26 additions and 29 deletions

View File

@@ -44,7 +44,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass(
// Load all the files in the directory // Load all the files in the directory
cmsys::Directory dir; cmsys::Directory dir;
if (dir.Load(tdir.c_str())) { if (dir.Load(tdir)) {
size_t numfiles = dir.GetNumberOfFiles(); size_t numfiles = dir.GetNumberOfFiles();
for (size_t i = 0; i < numfiles; ++i) { for (size_t i = 0; i < numfiles; ++i) {
std::string file = dir.GetFile(static_cast<unsigned long>(i)); std::string file = dir.GetFile(static_cast<unsigned long>(i));

View File

@@ -90,8 +90,7 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
std::string makecommand = std::string makecommand =
this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand( this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
target, configuration.c_str(), "", target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->IgnoreErrorsCMP0061());
this->Makefile->AddDefinition(variable, makecommand.c_str()); this->Makefile->AddDefinition(variable, makecommand.c_str());

View File

@@ -40,7 +40,7 @@ static std::string const kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES =
int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv, int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
bool isTryRun) bool isTryRun)
{ {
this->BinaryDirectory = argv[1].c_str(); this->BinaryDirectory = argv[1];
this->OutputFile = ""; this->OutputFile = "";
// which signature were we called with ? // which signature were we called with ?
this->SrcFileSignature = true; this->SrcFileSignature = true;
@@ -149,13 +149,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
} }
} }
} else if (doing == DoingOutputVariable) { } else if (doing == DoingOutputVariable) {
outputVariable = argv[i].c_str(); outputVariable = argv[i];
doing = DoingNone; doing = DoingNone;
} else if (doing == DoingCopyFile) { } else if (doing == DoingCopyFile) {
copyFile = argv[i].c_str(); copyFile = argv[i];
doing = DoingNone; doing = DoingNone;
} else if (doing == DoingCopyFileError) { } else if (doing == DoingCopyFileError) {
copyFileError = argv[i].c_str(); copyFileError = argv[i];
doing = DoingNone; doing = DoingNone;
} else if (doing == DoingSources) { } else if (doing == DoingSources) {
sources.push_back(argv[i]); sources.push_back(argv[i]);
@@ -163,7 +163,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
this->SrcFileSignature = false; this->SrcFileSignature = false;
projectName = argv[i].c_str(); projectName = argv[i].c_str();
} else if (i == 4 && !this->SrcFileSignature) { } else if (i == 4 && !this->SrcFileSignature) {
targetName = argv[i].c_str(); targetName = argv[i];
} else { } else {
std::ostringstream m; std::ostringstream m;
m << "try_compile given unknown argument \"" << argv[i] << "\"."; m << "try_compile given unknown argument \"" << argv[i] << "\".";

View File

@@ -82,8 +82,8 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
no_working_dir); no_working_dir);
cmSourceFile* sf = this->Makefile->GetSource(cxxres); cmSourceFile* sf = this->Makefile->GetSource(cxxres);
sf->AddDepend(hname.c_str()); sf->AddDepend(hname);
sf->AddDepend(origname.c_str()); sf->AddDepend(origname);
this->GeneratedSourcesClasses.push_back(sf); this->GeneratedSourcesClasses.push_back(sf);
} }
} }

View File

@@ -2600,7 +2600,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason. // Do not return error for compatibility reason.
std::string err = "Unexpected argument: "; std::string err = "Unexpected argument: ";
err += *i; err += *i;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
} }
++i; ++i;
} }
@@ -2884,7 +2884,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// Do not return error for compatibility reason. // Do not return error for compatibility reason.
std::string err = "Unexpected argument: "; std::string err = "Unexpected argument: ";
err += *i; err += *i;
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err.c_str()); this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, err);
} }
++i; ++i;

View File

@@ -69,7 +69,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
module += ".cmake"; module += ".cmake";
std::string mfile = this->Makefile->GetModulesFile(module.c_str()); std::string mfile = this->Makefile->GetModulesFile(module.c_str());
if (!mfile.empty()) { if (!mfile.empty()) {
fname = mfile.c_str(); fname = mfile;
} }
} }
@@ -111,7 +111,7 @@ bool cmIncludeCommand::InitialPass(std::vector<std::string> const& args,
} }
std::string listFile = cmSystemTools::CollapseFullPath( std::string listFile = cmSystemTools::CollapseFullPath(
fname.c_str(), this->Makefile->GetCurrentSourceDirectory()); fname, this->Makefile->GetCurrentSourceDirectory());
if (optional && !cmSystemTools::FileExists(listFile.c_str())) { if (optional && !cmSystemTools::FileExists(listFile.c_str())) {
if (!resultVarName.empty()) { if (!resultVarName.empty()) {
this->Makefile->AddDefinition(resultVarName, "NOTFOUND"); this->Makefile->AddDefinition(resultVarName, "NOTFOUND");

View File

@@ -986,7 +986,7 @@ bool cmInstallCommand::HandleDirectoryMode(
std::ostringstream e; std::ostringstream e;
e << args[0] << " does not allow \"" << args[i] e << args[0] << " does not allow \"" << args[i]
<< "\" after PATTERN or REGEX."; << "\" after PATTERN or REGEX.";
this->SetError(e.str().c_str()); this->SetError(e.str());
return false; return false;
} }
exclude_from_all = true; exclude_from_all = true;

View File

@@ -208,7 +208,7 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
} }
// Try to find the program. // Try to find the program.
std::string fullPath = cmSystemTools::FindFile(moduleName.c_str(), path); std::string fullPath = cmSystemTools::FindFile(moduleName, path);
if (fullPath == "") { if (fullPath == "") {
std::ostringstream e; std::ostringstream e;
e << "Attempt to load command failed from file \"" << moduleName << "\""; e << "Attempt to load command failed from file \"" << moduleName << "\"";
@@ -237,14 +237,14 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args,
// find the init function // find the init function
std::string initFuncName = args[0] + "Init"; std::string initFuncName = args[0] + "Init";
CM_INIT_FUNCTION initFunction = CM_INIT_FUNCTION initFunction =
(CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress( (CM_INIT_FUNCTION)cmsys::DynamicLoader::GetSymbolAddress(lib,
lib, initFuncName.c_str()); initFuncName);
if (!initFunction) { if (!initFunction) {
initFuncName = "_"; initFuncName = "_";
initFuncName += args[0]; initFuncName += args[0];
initFuncName += "Init"; initFuncName += "Init";
initFunction = (CM_INIT_FUNCTION)( initFunction = (CM_INIT_FUNCTION)(
cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName.c_str())); cmsys::DynamicLoader::GetSymbolAddress(lib, initFuncName));
} }
// if the symbol is found call it to set the name on the // if the symbol is found call it to set the name on the
// function blocker // function blocker

View File

@@ -206,7 +206,7 @@ protected:
std::string message = "Skipping "; std::string message = "Skipping ";
message += includeFile; message += includeFile;
message += " for file "; message += " for file ";
message += info->FullPath.c_str(); message += info->FullPath;
cmSystemTools::Error(message.c_str(), CM_NULLPTR); cmSystemTools::Error(message.c_str(), CM_NULLPTR);
} }
continue; continue;
@@ -520,7 +520,7 @@ bool cmOutputRequiredFilesCommand::InitialPass(
const cmDependInformation* info = md.FindDependencies(this->File.c_str()); const cmDependInformation* info = md.FindDependencies(this->File.c_str());
if (info) { if (info) {
// write them out // write them out
FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile.c_str(), "w"); FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w");
if (!fout) { if (!fout) {
std::string err = "Can not open output file: "; std::string err = "Can not open output file: ";
err += this->OutputFile; err += this->OutputFile;

View File

@@ -342,7 +342,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
return false; return false;
} }
} else if (this->PropertyName == "TYPE") { } else if (this->PropertyName == "TYPE") {
if (!cmState::IsCacheEntryType(this->PropertyValue.c_str())) { if (!cmState::IsCacheEntryType(this->PropertyValue)) {
std::ostringstream e; std::ostringstream e;
e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\""; e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
this->SetError(e.str()); this->SetError(e.str());

View File

@@ -69,7 +69,7 @@ bool cmSourceGroupCommand::InitialPass(std::vector<std::string> const& args,
src += "/"; src += "/";
src += args[i]; src += args[i];
} }
src = cmSystemTools::CollapseFullPath(src.c_str()); src = cmSystemTools::CollapseFullPath(src);
sg->AddGroupFile(src); sg->AddGroupFile(src);
} else { } else {
std::ostringstream err; std::ostringstream err;

View File

@@ -31,12 +31,10 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
// if they specified a relative path then compute the full // if they specified a relative path then compute the full
std::string srcPath = std::string srcPath =
std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + *i;
i->c_str();
if (cmSystemTools::FileIsDirectory(srcPath)) { if (cmSystemTools::FileIsDirectory(srcPath)) {
std::string binPath = std::string binPath =
std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + *i;
i->c_str();
this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false); this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
} }
// otherwise it is a full path // otherwise it is a full path

View File

@@ -108,5 +108,5 @@ void cmUseMangledMesaCommand::CopyAndFullPathMesaHeader(const char* source,
fin.close(); fin.close();
fout.close(); fout.close();
cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str()); cmSystemTools::CopyFileIfDifferent(tempOutputFile.c_str(), outFile.c_str());
cmSystemTools::RemoveFile(tempOutputFile.c_str()); cmSystemTools::RemoveFile(tempOutputFile);
} }

View File

@@ -65,7 +65,7 @@ bool cmWriteFileCommand::InitialPass(std::vector<std::string> const& args,
overwrite ? std::ios::out : std::ios::app); overwrite ? std::ios::out : std::ios::app);
if (!file) { if (!file) {
std::string error = "Internal CMake error when trying to open file: "; std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str(); error += fileName;
error += " for writing."; error += " for writing.";
this->SetError(error); this->SetError(error);
return false; return false;