diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 14:34:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 20:05:19 (GMT) |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/CTest/cmCTestCVS.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | CMake-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/CTest/cmCTestCVS.cxx')
-rw-r--r-- | Source/CTest/cmCTestCVS.cxx | 192 |
1 files changed, 83 insertions, 109 deletions
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 7ab87c2..5ddafbb 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -18,7 +18,8 @@ #include <cmsys/FStream.hxx> #include <cmsys/RegularExpression.hxx> -cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log): cmCTestVC(ct, log) +cmCTestCVS::cmCTestCVS(cmCTest* ct, std::ostream& log) + : cmCTestVC(ct, log) { } @@ -26,11 +27,12 @@ cmCTestCVS::~cmCTestCVS() { } -class cmCTestCVS::UpdateParser: public cmCTestVC::LineParser +class cmCTestCVS::UpdateParser : public cmCTestVC::LineParser { public: - UpdateParser(cmCTestCVS* cvs, const char* prefix): CVS(cvs) - { + UpdateParser(cmCTestCVS* cvs, const char* prefix) + : CVS(cvs) + { this->SetLog(&cvs->Log, prefix); // See "man cvs", section "update output". this->RegexFileUpdated.compile("^([UP]) *(.*)"); @@ -41,7 +43,8 @@ public: this->RegexFileRemoved2.compile( "cvs[^ ]* update: " "warning: `?([^']*)'? is not \\(any longer\\) pertinent"); - } + } + private: cmCTestCVS* CVS; cmsys::RegularExpression RegexFileUpdated; @@ -51,68 +54,55 @@ private: cmsys::RegularExpression RegexFileRemoved2; virtual bool ProcessLine() - { - if(this->RegexFileUpdated.find(this->Line)) - { + { + if (this->RegexFileUpdated.find(this->Line)) { this->DoFile(PathUpdated, this->RegexFileUpdated.match(2)); - } - else if(this->RegexFileModified.find(this->Line)) - { + } else if (this->RegexFileModified.find(this->Line)) { this->DoFile(PathModified, this->RegexFileModified.match(2)); - } - else if(this->RegexFileConflicting.find(this->Line)) - { + } else if (this->RegexFileConflicting.find(this->Line)) { this->DoFile(PathConflicting, this->RegexFileConflicting.match(2)); - } - else if(this->RegexFileRemoved1.find(this->Line)) - { + } else if (this->RegexFileRemoved1.find(this->Line)) { this->DoFile(PathUpdated, this->RegexFileRemoved1.match(1)); - } - else if(this->RegexFileRemoved2.find(this->Line)) - { + } else if (this->RegexFileRemoved2.find(this->Line)) { this->DoFile(PathUpdated, this->RegexFileRemoved2.match(1)); - } - return true; } + return true; + } void DoFile(PathStatus status, std::string const& file) - { + { std::string dir = cmSystemTools::GetFilenamePath(file); std::string name = cmSystemTools::GetFilenameName(file); this->CVS->Dirs[dir][name] = status; - } + } }; bool cmCTestCVS::UpdateImpl() { // Get user-specified update options. std::string opts = this->CTest->GetCTestConfiguration("UpdateOptions"); - if(opts.empty()) - { + if (opts.empty()) { opts = this->CTest->GetCTestConfiguration("CVSUpdateOptions"); - if(opts.empty()) - { + if (opts.empty()) { opts = "-dP"; - } } + } std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str()); // Specify the start time for nightly testing. - if(this->CTest->GetTestModel() == cmCTest::NIGHTLY) - { + if (this->CTest->GetTestModel() == cmCTest::NIGHTLY) { args.push_back("-D" + this->GetNightlyTime() + " UTC"); - } + } // Run "cvs update" to update the work tree. std::vector<char const*> cvs_update; cvs_update.push_back(this->CommandLineTool.c_str()); cvs_update.push_back("-z3"); cvs_update.push_back("update"); - for(std::vector<std::string>::const_iterator ai = args.begin(); - ai != args.end(); ++ai) - { + for (std::vector<std::string>::const_iterator ai = args.begin(); + ai != args.end(); ++ai) { cvs_update.push_back(ai->c_str()); - } + } cvs_update.push_back(0); UpdateParser out(this, "up-out> "); @@ -120,83 +110,76 @@ bool cmCTestCVS::UpdateImpl() return this->RunUpdateCommand(&cvs_update[0], &out, &err); } -class cmCTestCVS::LogParser: public cmCTestVC::LineParser +class cmCTestCVS::LogParser : public cmCTestVC::LineParser { public: typedef cmCTestCVS::Revision Revision; - LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs): - CVS(cvs), Revisions(revs), Section(SectionHeader) - { + LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs) + : CVS(cvs) + , Revisions(revs) + , Section(SectionHeader) + { this->SetLog(&cvs->Log, prefix), - this->RegexRevision.compile("^revision +([^ ]*) *$"); + this->RegexRevision.compile("^revision +([^ ]*) *$"); this->RegexBranches.compile("^branches: .*$"); this->RegexPerson.compile("^date: +([^;]+); +author: +([^;]+);"); - } + } + private: cmCTestCVS* CVS; std::vector<Revision>& Revisions; cmsys::RegularExpression RegexRevision; cmsys::RegularExpression RegexBranches; cmsys::RegularExpression RegexPerson; - enum SectionType { SectionHeader, SectionRevisions, SectionEnd }; + enum SectionType + { + SectionHeader, + SectionRevisions, + SectionEnd + }; SectionType Section; Revision Rev; virtual bool ProcessLine() - { - if(this->Line == ("=======================================" - "======================================")) - { + { + if (this->Line == ("=======================================" + "======================================")) { // This line ends the revision list. - if(this->Section == SectionRevisions) - { + if (this->Section == SectionRevisions) { this->FinishRevision(); - } - this->Section = SectionEnd; } - else if(this->Line == "----------------------------") - { + this->Section = SectionEnd; + } else if (this->Line == "----------------------------") { // This line divides revisions from the header and each other. - if(this->Section == SectionHeader) - { + if (this->Section == SectionHeader) { this->Section = SectionRevisions; - } - else if(this->Section == SectionRevisions) - { + } else if (this->Section == SectionRevisions) { this->FinishRevision(); - } } - else if(this->Section == SectionRevisions) - { - if(!this->Rev.Log.empty()) - { + } else if (this->Section == SectionRevisions) { + if (!this->Rev.Log.empty()) { // Continue the existing log. this->Rev.Log += this->Line; this->Rev.Log += "\n"; - } - else if(this->Rev.Rev.empty() && this->RegexRevision.find(this->Line)) - { + } else if (this->Rev.Rev.empty() && + this->RegexRevision.find(this->Line)) { this->Rev.Rev = this->RegexRevision.match(1); - } - else if(this->Rev.Date.empty() && this->RegexPerson.find(this->Line)) - { + } else if (this->Rev.Date.empty() && + this->RegexPerson.find(this->Line)) { this->Rev.Date = this->RegexPerson.match(1); this->Rev.Author = this->RegexPerson.match(2); - } - else if(!this->RegexBranches.find(this->Line)) - { + } else if (!this->RegexBranches.find(this->Line)) { // Start the log. this->Rev.Log += this->Line; this->Rev.Log += "\n"; - } } - return this->Section != SectionEnd; } + return this->Section != SectionEnd; + } void FinishRevision() - { - if(!this->Rev.Rev.empty()) - { + { + if (!this->Rev.Rev.empty()) { // Record this revision. /* clang-format off */ this->CVS->Log << "Found revision " << this->Rev.Rev << "\n" @@ -206,65 +189,57 @@ private: this->Revisions.push_back(this->Rev); // We only need two revisions. - if(this->Revisions.size() >= 2) - { + if (this->Revisions.size() >= 2) { this->Section = SectionEnd; - } } - this->Rev = Revision(); } + this->Rev = Revision(); + } }; std::string cmCTestCVS::ComputeBranchFlag(std::string const& dir) { // Compute the tag file location for this directory. std::string tagFile = this->SourceDirectory; - if(!dir.empty()) - { + if (!dir.empty()) { tagFile += "/"; tagFile += dir; - } + } tagFile += "/CVS/Tag"; // Lookup the branch in the tag file, if any. std::string tagLine; cmsys::ifstream tagStream(tagFile.c_str()); - if(tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) && - tagLine.size() > 1 && tagLine[0] == 'T') - { + if (tagStream && cmSystemTools::GetLineFromStream(tagStream, tagLine) && + tagLine.size() > 1 && tagLine[0] == 'T') { // Use the branch specified in the tag file. std::string flag = "-r"; flag += tagLine.substr(1); return flag; - } - else - { + } else { // Use the default branch. return "-b"; - } + } } -void cmCTestCVS::LoadRevisions(std::string const& file, - const char* branchFlag, +void cmCTestCVS::LoadRevisions(std::string const& file, const char* branchFlag, std::vector<Revision>& revisions) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush); // Run "cvs log" to get revisions of this file on this branch. const char* cvs = this->CommandLineTool.c_str(); - const char* cvs_log[] = - {cvs, "log", "-N", branchFlag, file.c_str(), 0}; + const char* cvs_log[] = { cvs, "log", "-N", branchFlag, file.c_str(), 0 }; LogParser out(this, "log-out> ", revisions); OutputLogger err(this->Log, "log-err> "); this->RunChild(cvs_log, &out, &err); } -void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, - std::string const& path, +void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path, Directory const& dir) { - const char* slash = path.empty()? "":"/"; + const char* slash = path.empty() ? "" : "/"; xml.StartElement("Directory"); xml.Element("Name", path); @@ -273,25 +248,23 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, // Load revisions and write an entry for each file in this directory. std::vector<Revision> revisions; - for(Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) - { + for (Directory::const_iterator fi = dir.begin(); fi != dir.end(); ++fi) { std::string full = path + slash + fi->first; // Load two real or unknown revisions. revisions.clear(); - if(fi->second != PathUpdated) - { + if (fi->second != PathUpdated) { // For local modifications the current rev is unknown and the // prior rev is the latest from cvs. revisions.push_back(this->Unknown); - } + } this->LoadRevisions(full, branchFlag.c_str(), revisions); revisions.resize(2, this->Unknown); // Write the entry for this file with these revisions. File f(fi->second, &revisions[0], &revisions[1]); this->WriteXMLEntry(xml, path, fi->first, full, f); - } + } xml.EndElement(); // Directory } @@ -299,13 +272,14 @@ bool cmCTestCVS::WriteXMLUpdates(cmXMLWriter& xml) { cmCTestLog(this->CTest, HANDLER_OUTPUT, " Gathering version information (one . per updated file):\n" - " " << std::flush); + " " + << std::flush); - for(std::map<std::string, Directory>::const_iterator - di = this->Dirs.begin(); di != this->Dirs.end(); ++di) - { + for (std::map<std::string, Directory>::const_iterator di = + this->Dirs.begin(); + di != this->Dirs.end(); ++di) { this->WriteXMLDirectory(xml, di->first, di->second); - } + } cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl); |