summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorCengizhan Pasaoglu <cengizhanpasaoglu@gmail.com>2018-11-06 06:47:40 (GMT)
committerCengizhan Pasaoglu <cengizhanpasaoglu@gmail.com>2018-11-06 18:43:33 (GMT)
commitc67ab22cdc680f6322e558b4f2c7cc74b6dbe163 (patch)
tree7197d12da074c751ad482f8dd9ed009a5f290198 /Source
parentbfdd1ba604a31b3bb9f0baa29ce6fce467ee2e47 (diff)
downloadCMake-c67ab22cdc680f6322e558b4f2c7cc74b6dbe163.zip
CMake-c67ab22cdc680f6322e558b4f2c7cc74b6dbe163.tar.gz
CMake-c67ab22cdc680f6322e558b4f2c7cc74b6dbe163.tar.bz2
Using front() and back() instead of calculations
Diffstat (limited to 'Source')
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx6
-rw-r--r--Source/cmArchiveWrite.cxx2
-rw-r--r--Source/cmCTest.cxx4
-rw-r--r--Source/cmCacheManager.cxx3
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx7
-rw-r--r--Source/cmExtraKateGenerator.cxx3
-rw-r--r--Source/cmFileCommand.cxx2
-rw-r--r--Source/cmFindBase.cxx4
-rw-r--r--Source/cmFindCommon.cxx4
-rw-r--r--Source/cmFindPackageCommand.cxx10
-rw-r--r--Source/cmGeneratorTarget.cxx5
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx10
-rw-r--r--Source/cmGlobalGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx2
-rw-r--r--Source/cmListCommand.cxx8
-rw-r--r--Source/cmLocalGenerator.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx2
-rw-r--r--Source/cmOrderDirectories.cxx2
-rw-r--r--Source/cmOutputConverter.cxx6
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx6
-rw-r--r--Source/cmRST.cxx3
-rw-r--r--Source/cmRulePlaceholderExpander.cxx4
-rw-r--r--Source/cmSetCommand.cxx8
-rw-r--r--Source/cmState.cxx8
-rw-r--r--Source/cmStringCommand.cxx7
-rw-r--r--Source/cmSystemTools.cxx4
-rw-r--r--Source/cmTarget.cxx2
-rw-r--r--Source/cmVisualStudioSlnParser.cxx6
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmcldeps.cxx2
-rw-r--r--Source/cmcmd.cxx24
33 files changed, 82 insertions, 88 deletions
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 75bd6fb..75e5aa4 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -20,7 +20,7 @@ bool cmAddSubDirectoryCommand::InitialPass(
}
// store the binpath
- std::string const& srcArg = args[0];
+ std::string const& srcArg = args.front();
std::string binArg;
bool excludeFromAll = false;
@@ -84,10 +84,10 @@ bool cmAddSubDirectoryCommand::InitialPass(
const std::string& bin = this->Makefile->GetCurrentBinaryDirectory();
size_t srcLen = src.length();
size_t binLen = bin.length();
- if (srcLen > 0 && src[srcLen - 1] == '/') {
+ if (srcLen > 0 && src.back() == '/') {
--srcLen;
}
- if (binLen > 0 && bin[binLen - 1] == '/') {
+ if (binLen > 0 && bin.back() == '/') {
--binLen;
}
binPath = bin.substr(0, binLen) + srcPath.substr(srcLen);
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 6031781..3f2e784 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -178,7 +178,7 @@ bool cmArchiveWrite::Add(std::string path, size_t skip, const char* prefix,
bool recursive)
{
if (this->Okay()) {
- if (!path.empty() && path[path.size() - 1] == '/') {
+ if (!path.empty() && path.back() == '/') {
path.erase(path.size() - 1);
}
this->AddPath(path.c_str(), skip, prefix, recursive);
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d0d5db6..9a046db 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -727,7 +727,7 @@ bool cmCTest::UpdateCTestConfiguration()
if (line.empty()) {
continue;
}
- while (fin && (line[line.size() - 1] == '\\')) {
+ while (fin && (line.back() == '\\')) {
line = line.substr(0, line.size() - 1);
buffer[0] = 0;
fin.getline(buffer, 1023);
@@ -2575,7 +2575,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
cmSystemTools::ConvertToUnixSlashes(*res);
path = "./" + *res;
- if (path[path.size() - 1] == '/') {
+ if (path.back() == '/') {
path = path.substr(0, path.size() - 1);
}
}
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index b391dc4..0305677 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -415,8 +415,7 @@ void cmCacheManager::OutputValueNoNewlines(std::ostream& fout,
std::string const& value)
{
// if value has trailing space or tab, enclose it in single quotes
- if (!value.empty() &&
- (value[value.size() - 1] == ' ' || value[value.size() - 1] == '\t')) {
+ if (!value.empty() && (value.back() == ' ' || value.back() == '\t')) {
fout << '\'' << value << '\'';
} else {
fout << value;
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 34f58ad..87ee382 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -976,9 +976,9 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
lg->GetIndividualFileTargets(objectFileTargets);
for (std::string const& f : objectFileTargets) {
const char* prefix = "[obj] ";
- if (f[f.length() - 1] == 's') {
+ if (f.back() == 's') {
prefix = "[to asm] ";
- } else if (f[f.length() - 1] == 'i') {
+ } else if (f.back() == 'i') {
prefix = "[pre] ";
}
this->AppendTarget(xml, f, make, makeArgs, subdir, prefix);
@@ -1035,8 +1035,7 @@ std::string cmExtraEclipseCDT4Generator::GetPathBasename(
{
std::string outputBasename = path;
while (!outputBasename.empty() &&
- (outputBasename[outputBasename.size() - 1] == '/' ||
- outputBasename[outputBasename.size() - 1] == '\\')) {
+ (outputBasename.back() == '/' || outputBasename.back() == '\\')) {
outputBasename.resize(outputBasename.size() - 1);
}
std::string::size_type loc = outputBasename.find_last_of("/\\");
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index f5c4c93..9410690 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -294,8 +294,7 @@ std::string cmExtraKateGenerator::GetPathBasename(
{
std::string outputBasename = path;
while (!outputBasename.empty() &&
- (outputBasename[outputBasename.size() - 1] == '/' ||
- outputBasename[outputBasename.size() - 1] == '\\')) {
+ (outputBasename.back() == '/' || outputBasename.back() == '\\')) {
outputBasename.resize(outputBasename.size() - 1);
}
std::string::size_type loc = outputBasename.find_last_of("/\\");
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 1f76703..f86e5e2 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2525,7 +2525,7 @@ bool cmFileCommand::HandleCMakePathCommand(
// remove double quotes in the path
std::string& s = *j;
- if (s.size() > 1 && s[0] == '\"' && s[s.size() - 1] == '\"') {
+ if (s.size() > 1 && s.front() == '\"' && s.back() == '\"') {
s = s.substr(1, s.size() - 2);
}
}
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 865595b..425546a 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -129,13 +129,13 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
this->VariableDocumentation += "the (unknown) library be found";
} else if (this->Names.size() == 1) {
this->VariableDocumentation +=
- "the " + this->Names[0] + " library be found";
+ "the " + this->Names.front() + " library be found";
} else {
this->VariableDocumentation += "one of the ";
this->VariableDocumentation +=
cmJoin(cmMakeRange(this->Names).retreat(1), ", ");
this->VariableDocumentation +=
- " or " + this->Names[this->Names.size() - 1] + " libraries be found";
+ " or " + this->Names.back() + " libraries be found";
}
}
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index fbaacfc..009f0e3 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -293,13 +293,13 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
if (suffix.empty()) {
return;
}
- if (suffix[0] == '/') {
+ if (suffix.front() == '/') {
suffix = suffix.substr(1);
}
if (suffix.empty()) {
return;
}
- if (suffix[suffix.size() - 1] == '/') {
+ if (suffix.back() == '/') {
suffix = suffix.substr(0, suffix.size() - 1);
}
if (suffix.empty()) {
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 96de6ad..97c1d7d 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -1429,7 +1429,7 @@ void cmFindPackageCommand::FillPrefixesUserHints()
bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
{
- assert(!dir.empty() && dir[dir.size() - 1] == '/');
+ assert(!dir.empty() && dir.back() == '/');
// Check each path suffix on this directory.
for (std::string const& s : this->SearchPathSuffixes) {
@@ -1447,7 +1447,7 @@ bool cmFindPackageCommand::SearchDirectory(std::string const& dir)
bool cmFindPackageCommand::CheckDirectory(std::string const& dir)
{
- assert(!dir.empty() && dir[dir.size() - 1] == '/');
+ assert(!dir.empty() && dir.back() == '/');
// Look for the file in this directory.
std::string d = dir.substr(0, dir.size() - 1);
@@ -2001,7 +2001,7 @@ private:
bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking prefix [%s]\n", prefix_in.c_str());
}
@@ -2157,7 +2157,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking framework prefix [%s]\n", prefix_in.c_str());
}
@@ -2218,7 +2218,7 @@ bool cmFindPackageCommand::SearchFrameworkPrefix(std::string const& prefix_in)
bool cmFindPackageCommand::SearchAppBundlePrefix(std::string const& prefix_in)
{
- assert(!prefix_in.empty() && prefix_in[prefix_in.size() - 1] == '/');
+ assert(!prefix_in.empty() && prefix_in.back() == '/');
if (this->DebugMode) {
fprintf(stderr, "Checking bundle prefix [%s]\n", prefix_in.c_str());
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 71947ea..1663400 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -953,7 +953,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
cmSystemTools::ExpandListArgument(entry, items);
for (std::string const& item : items) {
if (cmHasLiteralPrefix(item, "$<TARGET_OBJECTS:") &&
- item[item.size() - 1] == '>') {
+ item.back() == '>') {
continue;
}
files.push_back(item);
@@ -5612,8 +5612,7 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026(
std::vector<std::string> files;
cmSystemTools::ExpandListArgument(entry, files);
for (std::string const& li : files) {
- if (cmHasLiteralPrefix(li, "$<TARGET_OBJECTS:") &&
- li[li.size() - 1] == '>') {
+ if (cmHasLiteralPrefix(li, "$<TARGET_OBJECTS:") && li.back() == '>') {
std::string objLibName = li.substr(17, li.size() - 18);
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 1b358ab..ffb895e 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -19,8 +19,8 @@ bool cmGetFilenameComponentCommand::InitialPass(
// Check and see if the value has been stored in the cache
// already, if so use that value
- if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
- const char* cacheValue = this->Makefile->GetDefinition(args[0]);
+ if (args.size() >= 4 && args.back() == "CACHE") {
+ const char* cacheValue = this->Makefile->GetDefinition(args.front());
if (cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) {
return true;
}
@@ -113,20 +113,20 @@ bool cmGetFilenameComponentCommand::InitialPass(
return false;
}
- if (args.size() >= 4 && args[args.size() - 1] == "CACHE") {
+ if (args.size() >= 4 && args.back() == "CACHE") {
if (!programArgs.empty() && !storeArgs.empty()) {
this->Makefile->AddCacheDefinition(
storeArgs, programArgs.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
}
this->Makefile->AddCacheDefinition(
- args[0], result.c_str(), "",
+ args.front(), result.c_str(), "",
args[2] == "PATH" ? cmStateEnums::FILEPATH : cmStateEnums::STRING);
} else {
if (!programArgs.empty() && !storeArgs.empty()) {
this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
}
- this->Makefile->AddDefinition(args[0], result.c_str());
+ this->Makefile->AddDefinition(args.front(), result.c_str());
}
return true;
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 71e844e..cf85473 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2265,7 +2265,7 @@ bool cmGlobalGenerator::NameResolvesToFramework(
inline std::string removeQuotes(const std::string& s)
{
- if (s[0] == '\"' && s[s.size() - 1] == '\"') {
+ if (s.front() == '\"' && s.back() == '\"') {
return s.substr(1, s.size() - 2);
}
return s;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 8c69f42..fbc756c 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -838,7 +838,7 @@ static void EnsureTrailingSlash(std::string& path)
if (path.empty()) {
return;
}
- std::string::value_type last = path[path.size() - 1];
+ std::string::value_type last = path.back();
#ifdef _WIN32
if (last != '\\') {
path += '\\';
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 596bc6b..b7a361e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -546,7 +546,7 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
target->GetType() == cmStateEnums::STATIC_LIBRARY ||
target->GetType() == cmStateEnums::SHARED_LIBRARY ||
target->GetType() == cmStateEnums::MODULE_LIBRARY))) {
- makeHelper[makeHelper.size() - 1] = // fill placeholder
+ makeHelper.back() = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
cmCustomCommandLines commandLines;
commandLines.push_back(makeHelper);
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index b2acb90..9b63d24 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -152,7 +152,7 @@ bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args)
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
std::vector<std::string> varArgsExpanded;
// do not check the return value here
// if the list var is not found varArgsExpanded will have size 0
@@ -174,7 +174,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
// expand the variable
std::vector<std::string> varArgsExpanded;
if (!this->GetList(varArgsExpanded, listName)) {
@@ -243,7 +243,7 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
// expand the variable
std::vector<std::string> varArgsExpanded;
if (!this->GetList(varArgsExpanded, listName)) {
@@ -1176,7 +1176,7 @@ bool cmListCommand::HandleSublistCommand(std::vector<std::string> const& args)
}
const std::string& listName = args[1];
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
// expand the variable
std::vector<std::string> varArgsExpanded;
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a065408..a703f4d 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -807,19 +807,19 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
std::string includePath =
this->ConvertToIncludeReference(i, shellFormat, forceFullPaths);
- if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
+ if (quotePaths && !includePath.empty() && includePath.front() != '\"') {
includeFlags << "\"";
}
includeFlags << includePath;
- if (quotePaths && !includePath.empty() && includePath[0] != '\"') {
+ if (quotePaths && !includePath.empty() && includePath.front() != '\"') {
includeFlags << "\"";
}
includeFlags << sep;
}
std::string flags = includeFlags.str();
// remove trailing separators
- if ((sep[0] != ' ') && !flags.empty() && flags[flags.size() - 1] == sep[0]) {
- flags[flags.size() - 1] = ' ';
+ if ((sep[0] != ' ') && !flags.empty() && flags.back() == sep[0]) {
+ flags.back() = ' ';
}
return flags;
}
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 1da077e..7630691 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1347,7 +1347,7 @@ void cmLocalVisualStudio7Generator::OutputLibraryDirectories(
d != dirs.end(); ++d) {
// Remove any trailing slash and skip empty paths.
std::string dir = *d;
- if (dir[dir.size() - 1] == '/') {
+ if (dir.back() == '/') {
dir = dir.substr(0, dir.size() - 1);
}
if (dir.empty()) {
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index f423560..3c46784 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -590,7 +590,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
// mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c'
// (but 'a\ b "c"' as 'a\', 'b', and 'c'!). Workaround this by
// avoiding a trailing backslash in the argument.
- targetOutPathCompilePDB[targetOutPathCompilePDB.size() - 1] = '/';
+ targetOutPathCompilePDB.back() = '/';
}
}
cmRulePlaceholderExpander::RuleVariables vars;
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 04a9318..7fd7732 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -186,7 +186,7 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
// file name. Usually the soname starts with the library name.
std::string base = this->FileName;
std::set<std::string>::const_iterator first = files.lower_bound(base);
- ++base[base.size() - 1];
+ ++base.back();
std::set<std::string>::const_iterator last = files.upper_bound(base);
if (first != last) {
return true;
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index dbe6fa1..43a0107 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -118,11 +118,11 @@ std::string cmOutputConverter::ForceToRelativePath(
std::string const& local_path, std::string const& remote_path)
{
// The paths should never be quoted.
- assert(local_path[0] != '\"');
- assert(remote_path[0] != '\"');
+ assert(local_path.front() != '\"');
+ assert(remote_path.front() != '\"');
// The local path should never have a trailing slash.
- assert(local_path.empty() || local_path[local_path.size() - 1] != '/');
+ assert(local_path.empty() || local_path.back() != '/');
// If the path is already relative then just return the path.
if (!cmSystemTools::FileIsFullPath(remote_path)) {
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index e2de3f9..87c1ec0 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -340,7 +340,7 @@ protected:
} else {
// try to guess which include path to use
for (std::string incpath : this->IncludeDirectories) {
- if (!incpath.empty() && incpath[incpath.size() - 1] != '/') {
+ if (!incpath.empty() && incpath.back() != '/') {
incpath = incpath + "/";
}
incpath = incpath + path;
@@ -421,7 +421,7 @@ protected:
}
for (std::string path : this->IncludeDirectories) {
- if (!path.empty() && path[path.size() - 1] != '/') {
+ if (!path.empty() && path.back() != '/') {
path = path + "/";
}
path = path + fname;
@@ -435,7 +435,7 @@ protected:
if (extraPath) {
std::string path = extraPath;
- if (!path.empty() && path[path.size() - 1] != '/') {
+ if (!path.empty() && path.back() != '/') {
path = path + "/";
}
path = path + fname;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 32ad0b0..8a04c1f 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -228,8 +228,7 @@ void cmRST::ProcessLine(std::string const& line)
else {
this->NormalLine(line);
this->LastLineEndedInColonColon =
- (line.size() >= 2 && line[line.size() - 2] == ':' &&
- line[line.size() - 1] == ':');
+ (line.size() >= 2 && line[line.size() - 2] == ':' && line.back() == ':');
}
}
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index a71861a..0dfb797 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -110,7 +110,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
if (replaceValues.Target) {
if (variable == "TARGET_QUOTED") {
std::string targetQuoted = replaceValues.Target;
- if (!targetQuoted.empty() && targetQuoted[0] != '\"') {
+ if (!targetQuoted.empty() && targetQuoted.front() != '\"') {
targetQuoted = '\"';
targetQuoted += replaceValues.Target;
targetQuoted += '\"';
@@ -120,7 +120,7 @@ std::string cmRulePlaceholderExpander::ExpandRuleVariable(
if (variable == "TARGET_UNQUOTED") {
std::string unquoted = replaceValues.Target;
std::string::size_type sz = unquoted.size();
- if (sz > 2 && unquoted[0] == '\"' && unquoted[sz - 1] == '\"') {
+ if (sz > 2 && unquoted.front() == '\"' && unquoted.back() == '\"') {
unquoted = unquoted.substr(1, sz - 2);
}
return unquoted;
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 985aac8..1a2d1c6 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -54,7 +54,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
}
// SET (VAR PARENT_SCOPE) // Removes the definition of VAR
// in the parent scope.
- if (args.size() == 2 && args[args.size() - 1] == "PARENT_SCOPE") {
+ if (args.size() == 2 && args.back() == "PARENT_SCOPE") {
this->Makefile->RaiseScope(variable, nullptr);
return true;
}
@@ -74,12 +74,12 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
unsigned int ignoreLastArgs = 0;
// look for PARENT_SCOPE argument
- if (args.size() > 1 && args[args.size() - 1] == "PARENT_SCOPE") {
+ if (args.size() > 1 && args.back() == "PARENT_SCOPE") {
parentScope = true;
ignoreLastArgs++;
} else {
// look for FORCE argument
- if (args.size() > 4 && args[args.size() - 1] == "FORCE") {
+ if (args.size() > 4 && args.back() == "FORCE") {
force = true;
ignoreLastArgs++;
}
@@ -103,7 +103,7 @@ bool cmSetCommand::InitialPass(std::vector<std::string> const& args,
// we should be nice and try to catch some simple screwups if the last or
// next to last args are CACHE then they screwed up. If they used FORCE
// without CACHE they screwed up
- if ((args[args.size() - 1] == "CACHE") ||
+ if ((args.back() == "CACHE") ||
(args.size() > 1 && args[args.size() - 2] == "CACHE") ||
(force && !cache)) {
this->SetError("given invalid arguments for CACHE mode.");
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index a2008a0..4bbd2e0 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -867,8 +867,8 @@ static bool ParseEntryWithoutType(const std::string& entry, std::string& var,
// if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab
- if (flag && value.size() >= 2 && value[0] == '\'' &&
- value[value.size() - 1] == '\'') {
+ if (flag && value.size() >= 2 && value.front() == '\'' &&
+ value.back() == '\'') {
value = value.substr(1, value.size() - 2);
}
@@ -900,8 +900,8 @@ bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
// if value is enclosed in single quotes ('foo') then remove them
// it is used to enclose trailing space or tab
- if (flag && value.size() >= 2 && value[0] == '\'' &&
- value[value.size() - 1] == '\'') {
+ if (flag && value.size() >= 2 && value.front() == '\'' &&
+ value.back() == '\'') {
value = value.substr(1, value.size() - 2);
}
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 1605fd7..91d6190 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -156,7 +156,7 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
return false;
}
std::string::size_type cc;
- std::string const& outvar = args[args.size() - 1];
+ std::string const& outvar = args.back();
std::string output;
for (cc = 1; cc < args.size() - 1; cc++) {
int ch = atoi(args[cc].c_str());
@@ -755,7 +755,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
this->SetError("sub-command RANDOM invoked with bad length.");
return false;
}
- const std::string& variableName = args[args.size() - 1];
+ const std::string& variableName = args.back();
std::vector<char> result;
@@ -765,8 +765,7 @@ bool cmStringCommand::HandleRandomCommand(std::vector<std::string> const& args)
}
const char* alphaPtr = alphabet.c_str();
- int cc;
- for (cc = 0; cc < length; cc++) {
+ for (int cc = 0; cc < length; cc++) {
int idx = static_cast<int>(sizeofAlphabet * rand() / (RAND_MAX + 1.0));
result.push_back(*(alphaPtr + idx));
}
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 568ee82..9866d13 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -1301,7 +1301,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
int type /* = 0 */)
{
files.clear();
- if (glob[glob.size() - 1] != '*') {
+ if (glob.back() != '*') {
return false;
}
std::string path = cmSystemTools::GetFilenamePath(glob);
@@ -1318,7 +1318,7 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
if ((std::string(d.GetFile(i)) != ".") &&
(std::string(d.GetFile(i)) != "..")) {
std::string fname = path;
- if (path[path.size() - 1] != '/') {
+ if (path.back() != '/') {
fname += "/";
}
fname += d.GetFile(i);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 5d76a02..92d5505 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -87,7 +87,7 @@ const char* cmTargetPropertyComputer::GetSources<cmTarget>(
cmSystemTools::ExpandListArgument(entry, files);
for (std::string const& file : files) {
if (cmHasLiteralPrefix(file, "$<TARGET_OBJECTS:") &&
- file[file.size() - 1] == '>') {
+ file.back() == '>') {
std::string objLibName = file.substr(17, file.size() - 18);
if (cmGeneratorExpression::Find(objLibName) != std::string::npos) {
diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx
index a9acb3f..9353276 100644
--- a/Source/cmVisualStudioSlnParser.cxx
+++ b/Source/cmVisualStudioSlnParser.cxx
@@ -602,8 +602,8 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag,
}
const std::string& arg = cmSystemTools::TrimWhitespace(
fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1));
- if (arg[0] == '"') {
- if (arg[arg.size() - 1] != '"') {
+ if (arg.front() == '"') {
+ if (arg.back() != '"') {
this->LastResult.SetError(ResultErrorInputStructure,
state.GetCurrentLine());
return false;
@@ -620,7 +620,7 @@ bool cmVisualStudioSlnParser::ParseValue(const std::string& value,
const std::string& trimmed = cmSystemTools::TrimWhitespace(value);
if (trimmed.empty())
parsedLine.AddValue(trimmed);
- else if (trimmed[0] == '"' && trimmed[trimmed.size() - 1] == '"')
+ else if (trimmed.front() == '"' && trimmed.back() == '"')
parsedLine.AddQuotedValue(trimmed.substr(1, trimmed.size() - 2));
else
parsedLine.AddValue(trimmed);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 79af3e7..35730b8 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2129,7 +2129,7 @@ void cmake::TruncateOutputLog(const char* fname)
inline std::string removeQuotes(const std::string& s)
{
- if (s[0] == '\"' && s[s.size() - 1] == '\"') {
+ if (s.front() == '\"' && s.back() == '\"') {
return s.substr(1, s.size() - 2);
}
return s;
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index 0c5bbe2..1a10666 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -221,7 +221,7 @@ static int process(const std::string& srcfilename, const std::string& dfile,
while (std::getline(ss, line)) {
if (startsWith(line, prefix)) {
std::string inc = trimLeadingSpace(line.substr(prefix.size()).c_str());
- if (inc[inc.size() - 1] == '\r') // blech, stupid \r\n
+ if (inc.back() == '\r') // blech, stupid \r\n
inc = inc.substr(0, inc.size() - 1);
includes.push_back(inc);
} else {
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 8a140e8..45881aa 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -468,18 +468,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If multiple source files specified,
// then destination must be directory
if ((args.size() > 4) &&
- (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
- std::cerr << "Error: Target (for copy command) \""
- << args[args.size() - 1] << "\" is not a directory.\n";
+ (!cmSystemTools::FileIsDirectory(args.back()))) {
+ std::cerr << "Error: Target (for copy command) \"" << args.back()
+ << "\" is not a directory.\n";
return 1;
}
// If error occurs we want to continue copying next files.
bool return_value = false;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
if (!cmSystemTools::cmCopyFile(args[cc].c_str(),
- args[args.size() - 1].c_str())) {
+ args.back().c_str())) {
std::cerr << "Error copying file \"" << args[cc] << "\" to \""
- << args[args.size() - 1] << "\".\n";
+ << args.back() << "\".\n";
return_value = true;
}
}
@@ -491,18 +491,18 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If multiple source files specified,
// then destination must be directory
if ((args.size() > 4) &&
- (!cmSystemTools::FileIsDirectory(args[args.size() - 1]))) {
+ (!cmSystemTools::FileIsDirectory(args.back()))) {
std::cerr << "Error: Target (for copy_if_different command) \""
- << args[args.size() - 1] << "\" is not a directory.\n";
+ << args.back() << "\" is not a directory.\n";
return 1;
}
// If error occurs we want to continue copying next files.
bool return_value = false;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::CopyFileIfDifferent(
- args[cc].c_str(), args[args.size() - 1].c_str())) {
+ if (!cmSystemTools::CopyFileIfDifferent(args[cc].c_str(),
+ args.back().c_str())) {
std::cerr << "Error copying file (if different) from \"" << args[cc]
- << "\" to \"" << args[args.size() - 1] << "\".\n";
+ << "\" to \"" << args.back() << "\".\n";
return_value = true;
}
}
@@ -514,9 +514,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// If error occurs we want to continue copying next files.
bool return_value = false;
for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) {
- if (!cmSystemTools::CopyADirectory(args[cc], args[args.size() - 1])) {
+ if (!cmSystemTools::CopyADirectory(args[cc], args.back())) {
std::cerr << "Error copying directory from \"" << args[cc]
- << "\" to \"" << args[args.size() - 1] << "\".\n";
+ << "\" to \"" << args.back() << "\".\n";
return_value = true;
}
}