mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
Using front() and back() instead of calculations
This commit is contained in:
parent
bfdd1ba604
commit
c67ab22cdc
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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("/\\");
|
||||
|
@ -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("/\\");
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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 += '\\';
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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;
|
||||
|
@ -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() == ':');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user