summaryrefslogtreecommitdiffstats
path: root/Source/cmLoadCacheCommand.cxx
diff options
context:
space:
mode:
authorKitware Robot <kwrobot@kitware.com>2016-05-16 14:34:04 (GMT)
committerBrad King <brad.king@kitware.com>2016-05-16 20:05:19 (GMT)
commitd9fd2f5402eeaa345691313658e02b51038f570b (patch)
treedca71b9a7e267f4c6300da3eb770415381726785 /Source/cmLoadCacheCommand.cxx
parent82df6deaafb36cbbfd450202bb20b320f637751a (diff)
downloadCMake-d9fd2f5402eeaa345691313658e02b51038f570b.zip
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz
CMake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.bz2
Revise C++ coding style using clang-format
Run the `Utilities/Scripts/clang-format.bash` script to update all our C++ code to a new style defined by `.clang-format`. Use `clang-format` version 3.8. * If you reached this commit for a line in `git blame`, re-run the blame operation starting at the parent of this commit to see older history for the content. * See the parent commit for instructions to rebase a change across this style transition commit.
Diffstat (limited to 'Source/cmLoadCacheCommand.cxx')
-rw-r--r--Source/cmLoadCacheCommand.cxx136
1 files changed, 55 insertions, 81 deletions
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index 4865e56..85188d1 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -15,76 +15,63 @@
#include <cmsys/RegularExpression.hxx>
// cmLoadCacheCommand
-bool cmLoadCacheCommand
-::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+bool cmLoadCacheCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus&)
{
- if (args.size()< 1)
- {
+ if (args.size() < 1) {
this->SetError("called with wrong number of arguments.");
- }
+ }
- if(args.size() >= 2 && args[1] == "READ_WITH_PREFIX")
- {
+ if (args.size() >= 2 && args[1] == "READ_WITH_PREFIX") {
return this->ReadWithPrefix(args);
- }
+ }
// Cache entries to be excluded from the import list.
// If this set is empty, all cache entries are brought in
// and they can not be overridden.
- bool excludeFiles=false;
+ bool excludeFiles = false;
unsigned int i;
std::set<std::string> excludes;
- for(i=0; i<args.size(); i++)
- {
- if (excludeFiles)
- {
+ for (i = 0; i < args.size(); i++) {
+ if (excludeFiles) {
excludes.insert(args[i]);
- }
- if (args[i] == "EXCLUDE")
- {
- excludeFiles=true;
- }
- if (excludeFiles && (args[i] == "INCLUDE_INTERNALS"))
- {
+ }
+ if (args[i] == "EXCLUDE") {
+ excludeFiles = true;
+ }
+ if (excludeFiles && (args[i] == "INCLUDE_INTERNALS")) {
break;
- }
}
+ }
// Internal cache entries to be imported.
// If this set is empty, no internal cache entries are
// brought in.
- bool includeFiles=false;
+ bool includeFiles = false;
std::set<std::string> includes;
- for(i=0; i<args.size(); i++)
- {
- if (includeFiles)
- {
+ for (i = 0; i < args.size(); i++) {
+ if (includeFiles) {
includes.insert(args[i]);
- }
- if (args[i] == "INCLUDE_INTERNALS")
- {
- includeFiles=true;
- }
- if (includeFiles && (args[i] == "EXCLUDE"))
- {
+ }
+ if (args[i] == "INCLUDE_INTERNALS") {
+ includeFiles = true;
+ }
+ if (includeFiles && (args[i] == "EXCLUDE")) {
break;
- }
}
+ }
// Loop over each build directory listed in the arguments. Each
// directory has a cache file.
- for(i=0; i<args.size(); i++)
- {
- if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS"))
- {
+ for (i = 0; i < args.size(); i++) {
+ if ((args[i] == "EXCLUDE") || (args[i] == "INCLUDE_INTERNALS")) {
break;
- }
- this->Makefile->GetCMakeInstance()->LoadCache(args[i], false,
- excludes, includes);
}
-
+ this->Makefile->GetCMakeInstance()->LoadCache(args[i], false, excludes,
+ includes);
+ }
return true;
}
@@ -92,20 +79,18 @@ bool cmLoadCacheCommand
bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
{
// Make sure we have a prefix.
- if(args.size() < 3)
- {
+ if (args.size() < 3) {
this->SetError("READ_WITH_PREFIX form must specify a prefix.");
return false;
- }
+ }
// Make sure the cache file exists.
- std::string cacheFile = args[0]+"/CMakeCache.txt";
- if(!cmSystemTools::FileExists(cacheFile.c_str()))
- {
+ std::string cacheFile = args[0] + "/CMakeCache.txt";
+ if (!cmSystemTools::FileExists(cacheFile.c_str())) {
std::string e = "Cannot load cache file from " + cacheFile;
this->SetError(e);
return false;
- }
+ }
// Prepare the table of variables to read.
this->Prefix = args[2];
@@ -120,47 +105,41 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
const int bufferSize = 4096;
char buffer[bufferSize];
std::string line;
- while(fin)
- {
+ while (fin) {
// Read a block of the file.
fin.read(buffer, bufferSize);
- if(fin.gcount())
- {
+ if (fin.gcount()) {
// Parse for newlines directly.
const char* i = buffer;
- const char* end = buffer+fin.gcount();
- while(i != end)
- {
+ const char* end = buffer + fin.gcount();
+ while (i != end) {
const char* begin = i;
- while(i != end && *i != '\n') { ++i; }
- if(i == begin || *(i-1) != '\r')
- {
+ while (i != end && *i != '\n') {
+ ++i;
+ }
+ if (i == begin || *(i - 1) != '\r') {
// Include this portion of the line.
- line += std::string(begin, i-begin);
- }
- else
- {
+ line += std::string(begin, i - begin);
+ } else {
// Include this portion of the line.
// Don't include the \r in a \r\n pair.
- line += std::string(begin, i-1-begin);
- }
- if(i != end)
- {
+ line += std::string(begin, i - 1 - begin);
+ }
+ if (i != end) {
// Completed a line.
this->CheckLine(line.c_str());
line = "";
// Skip the newline character.
++i;
- }
}
}
}
- if(!line.empty())
- {
+ }
+ if (!line.empty()) {
// Partial last line.
this->CheckLine(line.c_str());
- }
+ }
return true;
}
@@ -171,22 +150,17 @@ void cmLoadCacheCommand::CheckLine(const char* line)
std::string var;
std::string value;
cmState::CacheEntryType type = cmState::UNINITIALIZED;
- if(cmake::ParseCacheEntry(line, var, value, type))
- {
+ if (cmake::ParseCacheEntry(line, var, value, type)) {
// Found a real entry. See if this one was requested.
- if(this->VariablesToRead.find(var) != this->VariablesToRead.end())
- {
+ if (this->VariablesToRead.find(var) != this->VariablesToRead.end()) {
// This was requested. Set this variable locally with the given
// prefix.
var = this->Prefix + var;
- if(!value.empty())
- {
+ if (!value.empty()) {
this->Makefile->AddDefinition(var, value.c_str());
- }
- else
- {
+ } else {
this->Makefile->RemoveDefinition(var);
- }
}
}
+ }
}