Merge topic 'tidy-readability-redundant-string-cstr'

60dcaaea tidy: Fix readability-redundant-string-cstr issues
This commit is contained in:
Brad King 2016-09-05 09:29:30 -04:00 committed by CMake Topic Stage
commit 750789af42
9 changed files with 60 additions and 67 deletions

View File

@ -330,8 +330,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
if (!cpack_dmg_disable_applications_symlink) {
std::ostringstream application_link;
application_link << staging.str() << "/Applications";
cmSystemTools::CreateSymlink("/Applications",
application_link.str().c_str());
cmSystemTools::CreateSymlink("/Applications", application_link.str());
}
// Optionally add a custom volume icon ...
@ -755,7 +754,7 @@ std::string cmCPackDragNDropGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar =
"CPACK_COMPONENT_" + cmSystemTools::UpperCase(componentName) + "_GROUP";
const char* _groupName = GetOption(groupVar.c_str());
const char* _groupName = GetOption(groupVar);
if (_groupName) {
std::string groupName = _groupName;

View File

@ -102,15 +102,14 @@ int cmCPackOSXX11Generator::PackageFiles()
}
std::string applicationsLinkName = diskImageDirectory + "/Applications";
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName.c_str());
cmSystemTools::CreateSymlink("/Applications", applicationsLinkName);
if (!this->CopyResourcePlistFile("VolumeIcon.icns",
diskImageDirectory.c_str(),
if (!this->CopyResourcePlistFile("VolumeIcon.icns", diskImageDirectory,
".VolumeIcon.icns", true) ||
!this->CopyResourcePlistFile("DS_Store", diskImageDirectory.c_str(),
".DS_Store", true) ||
!this->CopyResourcePlistFile("DS_Store", diskImageDirectory, ".DS_Store",
true) ||
!this->CopyResourcePlistFile("background.png",
diskImageBackgroundImageDir.c_str(),
diskImageBackgroundImageDir,
"background.png", true) ||
!this->CopyResourcePlistFile("RuntimeScript", dir) ||
!this->CopyResourcePlistFile("OSXX11.Info.plist", contDir,

View File

@ -225,8 +225,7 @@ void cmCPackPKGGenerator::CreateChoice(const cmCPackComponent& component,
dirName += '/';
dirName += component.Name;
dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
unsigned long installedSize =
component.GetInstalledSizeInKbytes(dirName.c_str());
unsigned long installedSize = component.GetInstalledSizeInKbytes(dirName);
xout.StartElement("pkg-ref");
xout.Attribute("id", packageId);
@ -283,7 +282,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
const char* inFileName = this->GetOption(cpackVar.c_str());
const char* inFileName = this->GetOption(cpackVar);
if (!inFileName) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: "
<< cpackVar.c_str()
@ -314,7 +313,7 @@ bool cmCPackPKGGenerator::CopyCreateResourceFile(const std::string& name,
// Set this so that distribution.dist gets the right name (without
// the path).
this->SetOption(("CPACK_RESOURCE_FILE_" + uname + "_NOPATH").c_str(),
this->SetOption("CPACK_RESOURCE_FILE_" + uname + "_NOPATH",
(name + ext).c_str());
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
@ -358,7 +357,7 @@ int cmCPackPKGGenerator::CopyInstallScript(const std::string& resdir,
std::string dst = resdir;
dst += "/";
dst += name;
cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
cmSystemTools::CopyFileAlways(script, dst);
cmSystemTools::SetPermissions(dst.c_str(), 0777);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"copy script : " << script << "\ninto " << dst << std::endl);

View File

@ -118,13 +118,13 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// then copy them into the resource directory and make
// them executable
if (preflight) {
this->CopyInstallScript(resDir.c_str(), preflight, "preflight");
this->CopyInstallScript(resDir, preflight, "preflight");
}
if (postflight) {
this->CopyInstallScript(resDir.c_str(), postflight, "postflight");
this->CopyInstallScript(resDir, postflight, "postflight");
}
if (postupgrade) {
this->CopyInstallScript(resDir.c_str(), postupgrade, "postupgrade");
this->CopyInstallScript(resDir, postupgrade, "postupgrade");
}
} else if (postflight) {
// create a postflight component to house the script
@ -160,7 +160,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
// copy postflight script into resource directory of .pkg
std::string resourceDir = packageFile + "/Contents/Resources";
this->CopyInstallScript(resourceDir.c_str(), postflight, "postflight");
this->CopyInstallScript(resourceDir, postflight, "postflight");
}
if (!this->Components.empty()) {
@ -254,9 +254,9 @@ int cmCPackPackageMakerGenerator::PackageFiles()
this->SetOption("CPACK_MODULE_VERSION_SUFFIX", "");
// Copy or create all of the resource files we need.
if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
!this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
!this->CopyCreateResourceFile("Welcome", resDir.c_str()) ||
if (!this->CopyCreateResourceFile("License", resDir) ||
!this->CopyCreateResourceFile("ReadMe", resDir) ||
!this->CopyCreateResourceFile("Welcome", resDir) ||
!this->CopyResourcePlistFile("Info.plist") ||
!this->CopyResourcePlistFile("Description.plist")) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
@ -372,7 +372,7 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
}
// Get path to the real PackageMaker, not a symlink:
pkgPath = cmSystemTools::GetRealPath(pkgPath.c_str());
pkgPath = cmSystemTools::GetRealPath(pkgPath);
// Up from there to find the version.plist file in the "Contents" dir:
std::string contents_dir;
contents_dir = cmSystemTools::GetFilenamePath(pkgPath);

View File

@ -73,9 +73,9 @@ int cmCPackProductBuildGenerator::PackageFiles()
// Copy or create all of the resource files we need.
std::string resDir = packageDirFileName + "/Contents";
if (!this->CopyCreateResourceFile("License", resDir.c_str()) ||
!this->CopyCreateResourceFile("ReadMe", resDir.c_str()) ||
!this->CopyCreateResourceFile("Welcome", resDir.c_str())) {
if (!this->CopyCreateResourceFile("License", resDir) ||
!this->CopyCreateResourceFile("ReadMe", resDir) ||
!this->CopyCreateResourceFile("Welcome", resDir)) {
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying the resource files"
<< std::endl);
return 0;
@ -185,10 +185,10 @@ bool cmCPackProductBuildGenerator::GenerateComponentPackage(
// then copy them into the script directory and make
// them executable
if (preflight) {
this->CopyInstallScript(scriptDir.c_str(), preflight, "preinstall");
this->CopyInstallScript(scriptDir, preflight, "preinstall");
}
if (postflight) {
this->CopyInstallScript(scriptDir.c_str(), postflight, "postinstall");
this->CopyInstallScript(scriptDir, postflight, "postinstall");
}
// The command that will be used to run ProductBuild

View File

@ -80,7 +80,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
std::string str;
if (cmSystemTools::GetEnv(var, str)) {
if (this->EscapeQuotes) {
return this->AddString(cmSystemTools::EscapeQuotes(str.c_str()));
return this->AddString(cmSystemTools::EscapeQuotes(str));
}
return this->AddString(str);
}

View File

@ -118,7 +118,7 @@ std::string cmFilePathUuid::GetChecksumString(
// Calculate the file ( seed + relative path + name ) checksum
std::vector<unsigned char> hashBytes =
cmCryptoHash::New("SHA256")->ByteHashString(
(sourceRelSeed + sourceRelPath + sourceFilename).c_str());
sourceRelSeed + sourceRelPath + sourceFilename);
checksumBase32 =
cmBase32Encoder().encodeString(&hashBytes[0], hashBytes.size(), false);

View File

@ -397,7 +397,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
std::string listfile = root->GetCurrentSourceDirectory();
listfile += "/";
listfile += "CMakeLists.txt";
allBuildGt->AddSource(listfile.c_str());
allBuildGt->AddSource(listfile);
// Add XCODE depend helper
std::string dir = root->GetCurrentBinaryDirectory();
@ -405,9 +405,9 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
if (this->XcodeVersion < 50) {
makeHelper.push_back("make");
makeHelper.push_back("-C");
makeHelper.push_back(dir.c_str());
makeHelper.push_back(dir);
makeHelper.push_back("-f");
makeHelper.push_back(this->CurrentXCodeHackMakefile.c_str());
makeHelper.push_back(this->CurrentXCodeHackMakefile);
makeHelper.push_back(""); // placeholder, see below
}
@ -480,7 +480,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
listfile = lg->GetCurrentSourceDirectory();
listfile += "/";
listfile += "CMakeLists.txt";
target->AddSource(listfile.c_str());
target->AddSource(listfile);
}
}
}
@ -841,7 +841,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
// lastKnownFileType as folder in order for Xcode to be able to
// open the contents of the folder.
// (Xcode 4.6 does not like explicitFileType=folder).
if (cmSystemTools::FileIsDirectory(fullpath.c_str())) {
if (cmSystemTools::FileIsDirectory(fullpath)) {
fileType = (ext == "xcassets" ? "folder.assetcatalog" : "folder");
useLastKnownFileType = true;
} else {
@ -856,7 +856,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
// Store the file path relative to the top of the source tree.
std::string path = this->RelativeToSource(fullpath.c_str());
std::string name = cmSystemTools::GetFilenameName(path.c_str());
std::string name = cmSystemTools::GetFilenameName(path);
const char* sourceTree =
(cmSystemTools::FileIsFullPath(path.c_str()) ? "<absolute>"
: "SOURCE_ROOT");
@ -898,8 +898,7 @@ void cmGlobalXCodeGenerator::SetCurrentLocalGenerator(cmLocalGenerator* gen)
this->CurrentMakefile = gen->GetMakefile();
std::string outdir = cmSystemTools::CollapseFullPath(
this->CurrentLocalGenerator->GetCurrentBinaryDirectory());
cmSystemTools::SplitPath(outdir.c_str(),
this->CurrentOutputDirectoryComponents);
cmSystemTools::SplitPath(outdir, this->CurrentOutputDirectoryComponents);
// Select the current set of configuration types.
this->CurrentConfigurationTypes.clear();
@ -951,7 +950,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeTargets(
std::string targetName = gtgt->GetName();
// make sure ALL_BUILD, INSTALL, etc are only done once
if (this->SpecialTargetEmitted(targetName.c_str())) {
if (this->SpecialTargetEmitted(targetName)) {
continue;
}
@ -1223,7 +1222,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt)
cmGeneratedFileStream fout(fname.c_str());
fout << "\n";
}
if (cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str())) {
if (cmSourceFile* sf = mf->GetOrCreateSource(fname)) {
sf->SetProperty("LANGUAGE", llang.c_str());
gtgt->AddSource(fname);
}
@ -1468,7 +1467,7 @@ void cmGlobalXCodeGenerator::AddCommandsToBuildPhase(
currentConfig != this->CurrentConfigurationTypes.end();
currentConfig++) {
this->CreateCustomRulesMakefile(makefile.c_str(), target, commands,
currentConfig->c_str());
*currentConfig);
}
std::string cdir = this->CurrentLocalGenerator->GetCurrentBinaryDirectory();
@ -1550,8 +1549,8 @@ void cmGlobalXCodeGenerator::CreateCustomRulesMakefile(
ccg.GetDepends().begin();
d != ccg.GetDepends().end(); ++d) {
std::string dep;
if (this->CurrentLocalGenerator->GetRealDependency(d->c_str(),
configName, dep)) {
if (this->CurrentLocalGenerator->GetRealDependency(*d, configName,
dep)) {
makefileStream << "\\\n"
<< this->ConvertToRelativeForMake(dep.c_str());
}
@ -1662,7 +1661,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
}
if (!extraLinkOptionsVar.empty()) {
this->CurrentLocalGenerator->AddConfigVariableFlags(
extraLinkOptions, extraLinkOptionsVar.c_str(), configName);
extraLinkOptions, extraLinkOptionsVar, configName);
}
if (gtgt->GetType() == cmState::OBJECT_LIBRARY ||
@ -1678,7 +1677,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
if (!configName.empty()) {
std::string linkFlagsVar = "LINK_FLAGS_";
linkFlagsVar += cmSystemTools::UpperCase(configName);
if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar.c_str())) {
if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar)) {
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, linkFlags);
}
}
@ -1916,7 +1915,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
configName);
for (std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i) {
if (this->NameResolvesToFramework(i->c_str())) {
if (this->NameResolvesToFramework(*i)) {
std::string frameworkDir = *i;
frameworkDir += "/../";
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
@ -2165,7 +2164,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string processed =
ge.Parse(gtgt->GetProperty(*i))
->Evaluate(this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute.c_str(),
buildSettings->AddAttribute(attribute,
this->CreateString(processed));
}
}
@ -2195,7 +2194,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
cmXCodeObject* target =
this->CreateObject(cmXCodeObject::PBXAggregateTarget);
target->SetComment(gtgt->GetName().c_str());
target->SetComment(gtgt->GetName());
cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST);
std::vector<cmXCodeObject*> emptyContentVector;
this->CreateCustomCommands(buildPhases, 0, 0, 0, emptyContentVector, 0,
@ -2233,7 +2232,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget(
}
}
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()).c_str());
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()));
return target;
}
@ -2257,7 +2256,7 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
comment += " \"";
comment += gtgt->GetName();
comment += "\"";
configlist->SetComment(comment.c_str());
configlist->SetComment(comment);
target->AddAttribute("buildConfigurationList",
this->CreateObjectReference(configlist));
for (unsigned int i = 0; i < configVector.size(); ++i) {
@ -2266,9 +2265,9 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
buildConfigurations->AddObject(config);
cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
this->CreateBuildSettings(gtgt, buildSettings, configVector[i].c_str());
this->CreateBuildSettings(gtgt, buildSettings, configVector[i]);
config->AddAttribute("name", this->CreateString(configVector[i]));
config->SetComment(configVector[i].c_str());
config->SetComment(configVector[i]);
config->AddAttribute("buildSettings", buildSettings);
}
if (!configVector.empty()) {
@ -2367,7 +2366,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
defConfig = this->CurrentMakefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->CreateBuildSettings(gtgt, buildSettings, defConfig.c_str());
this->CreateBuildSettings(gtgt, buildSettings, defConfig);
target->AddAttribute("buildSettings", buildSettings);
}
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
@ -2385,7 +2384,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
fullName += gtgt->GetName();
fullName += ".a";
} else {
fullName = gtgt->GetFullName(defConfig.c_str());
fullName = gtgt->GetFullName(defConfig);
}
fileRef->AddAttribute("path", this->CreateString(fullName));
if (this->XcodeVersion == 15) {
@ -2393,7 +2392,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
}
fileRef->AddAttribute("sourceTree",
this->CreateString("BUILT_PRODUCTS_DIR"));
fileRef->SetComment(gtgt->GetName().c_str());
fileRef->SetComment(gtgt->GetName());
target->AddAttribute("productReference",
this->CreateObjectReference(fileRef));
if (const char* productType = this->GetTargetProductType(gtgt)) {
@ -2401,7 +2400,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeTarget(
}
target->SetTarget(gtgt);
this->XCodeObjectMap[gtgt] = target;
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()).c_str());
target->SetId(this->GetOrCreateId(gtgt->GetName(), target->GetId()));
return target;
}
@ -2426,15 +2425,14 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
const char* storedGUID =
this->CMakeInstance->GetCacheDefinition(guidStoreName.c_str());
this->CMakeInstance->GetCacheDefinition(guidStoreName);
if (storedGUID) {
return storedGUID;
}
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(), id.c_str(),
"Stored Xcode object GUID",
cmState::INTERNAL);
this->CMakeInstance->AddCacheEntry(
guidStoreName, id.c_str(), "Stored Xcode object GUID", cmState::INTERNAL);
return id;
}
@ -2482,7 +2480,7 @@ void cmGlobalXCodeGenerator::AppendOrAddBuildSetting(cmXCodeObject* settings,
std::string oldValue = attr->GetString();
oldValue += " ";
oldValue += value;
attr->SetString(oldValue.c_str());
attr->SetString(oldValue);
}
}
}
@ -2582,7 +2580,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target)
std::vector<std::string> const& libDeps = cli.GetDepends();
for (std::vector<std::string>::const_iterator j = libDeps.begin();
j != libDeps.end(); ++j) {
target->AddDependLibrary(configName, j->c_str());
target->AddDependLibrary(configName, *j);
}
}
@ -2891,8 +2889,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
std::string project_id = "PROJECT_";
project_id += root->GetProjectName();
this->RootObject->SetId(
this->GetOrCreateId(project_id.c_str(), this->RootObject->GetId())
.c_str());
this->GetOrCreateId(project_id.c_str(), this->RootObject->GetId()));
group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
this->RootObject->AddAttribute("mainGroup",
@ -2963,7 +2960,7 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
comment += " \"";
comment += this->CurrentProject;
comment += "\"";
configlist->SetComment(comment.c_str());
configlist->SetComment(comment);
configlist->AddAttribute("defaultConfigurationIsVisible",
this->CreateString("0"));
configlist->AddAttribute("defaultConfigurationName",
@ -3373,8 +3370,7 @@ std::string cmGlobalXCodeGenerator::LookupFlags(
std::string varName = varNamePrefix;
varName += varNameLang;
varName += varNameSuffix;
if (const char* varValue =
this->CurrentMakefile->GetDefinition(varName.c_str())) {
if (const char* varValue = this->CurrentMakefile->GetDefinition(varName)) {
if (*varValue) {
return varValue;
}

View File

@ -1373,7 +1373,7 @@ void cmLocalGenerator::GetTargetDefines(cmGeneratorTarget const* target,
}
// Add preprocessor definitions for this target and configuration.
this->AddCompileDefinitions(defines, target, config, lang.c_str());
this->AddCompileDefinitions(defines, target, config, lang);
}
std::string cmLocalGenerator::GetTargetFortranFlags(