summaryrefslogtreecommitdiff
path: root/Source/cmFindCommon.cxx
diff options
context:
space:
mode:
authorPavel Solodovnikov <hellyeahdominate@gmail.com>2017-09-11 13:40:26 +0300
committerPavel Solodovnikov <hellyeahdominate@gmail.com>2017-09-12 16:22:47 +0300
commit7d5095796ab616cf9b709036387bb95ab9984141 (patch)
treec010e922adad95ef86ab4a3ac2a3abd63e9f33ef /Source/cmFindCommon.cxx
parent00975e926199eea21763470e2ab876246e36669a (diff)
downloadcmake-7d5095796ab616cf9b709036387bb95ab9984141.tar.gz
Meta: modernize old-fashioned loops to range-based `for`.
Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
Diffstat (limited to 'Source/cmFindCommon.cxx')
-rw-r--r--Source/cmFindCommon.cxx38
1 files changed, 16 insertions, 22 deletions
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 9ebe824902..814296201a 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -155,10 +155,9 @@ void cmFindCommon::SelectDefaultMacMode()
void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
{
#if 0
- for(std::vector<std::string>::const_iterator i = paths.begin();
- i != paths.end(); ++i)
+ for(std::string const& p : paths)
{
- fprintf(stderr, "[%s]\n", i->c_str());
+ fprintf(stderr, "[%s]\n", p.c_str());
}
#endif
// Short-circuit if there is nothing to do.
@@ -194,9 +193,8 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
if (sysroot) {
roots.push_back(sysroot);
}
- for (std::vector<std::string>::iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- cmSystemTools::ConvertToUnixSlashes(*ri);
+ for (std::string& r : roots) {
+ cmSystemTools::ConvertToUnixSlashes(r);
}
const char* stagePrefix =
@@ -206,24 +204,22 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
std::vector<std::string> unrootedPaths = paths;
paths.clear();
- for (std::vector<std::string>::const_iterator ri = roots.begin();
- ri != roots.end(); ++ri) {
- for (std::vector<std::string>::const_iterator ui = unrootedPaths.begin();
- ui != unrootedPaths.end(); ++ui) {
+ for (std::string const& r : roots) {
+ for (std::string const& up : unrootedPaths) {
// Place the unrooted path under the current root if it is not
// already inside. Skip the unrooted path if it is relative to
// a user home directory or is empty.
std::string rootedDir;
- if (cmSystemTools::IsSubDirectory(*ui, *ri) ||
- (stagePrefix && cmSystemTools::IsSubDirectory(*ui, stagePrefix))) {
- rootedDir = *ui;
- } else if (!ui->empty() && (*ui)[0] != '~') {
+ if (cmSystemTools::IsSubDirectory(up, r) ||
+ (stagePrefix && cmSystemTools::IsSubDirectory(up, stagePrefix))) {
+ rootedDir = up;
+ } else if (!up.empty() && up[0] != '~') {
// Start with the new root.
- rootedDir = *ri;
+ rootedDir = r;
rootedDir += "/";
// Append the original path with its old root removed.
- rootedDir += cmSystemTools::SplitPathRootComponent(*ui);
+ rootedDir += cmSystemTools::SplitPathRootComponent(up);
}
// Store the new path.
@@ -255,9 +251,8 @@ void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
cmSystemTools::ExpandListArgument(ignorePath, ignore);
}
- for (std::vector<std::string>::iterator i = ignore.begin();
- i != ignore.end(); ++i) {
- cmSystemTools::ConvertToUnixSlashes(*i);
+ for (std::string& i : ignore) {
+ cmSystemTools::ConvertToUnixSlashes(i);
}
}
@@ -337,9 +332,8 @@ void cmFindCommon::ComputeFinalPaths()
// Combine the seperate path types, filtering out ignores
this->SearchPaths.clear();
std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
- for (std::vector<PathLabel>::const_iterator l = allLabels.begin();
- l != allLabels.end(); ++l) {
- this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
+ for (PathLabel const& l : allLabels) {
+ this->LabeledPaths[l].ExtractWithout(ignored, this->SearchPaths);
}
// Expand list of paths inside all search roots.