diff options
author | Kitware Robot <kwrobot@kitware.com> | 2016-05-16 10:34:04 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-16 16:05:19 -0400 |
commit | d9fd2f5402eeaa345691313658e02b51038f570b (patch) | |
tree | dca71b9a7e267f4c6300da3eb770415381726785 /Source/CTest/cmParsePHPCoverage.cxx | |
parent | 82df6deaafb36cbbfd450202bb20b320f637751a (diff) | |
download | cmake-d9fd2f5402eeaa345691313658e02b51038f570b.tar.gz |
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/cmParsePHPCoverage.cxx')
-rw-r--r-- | Source/CTest/cmParsePHPCoverage.cxx | 183 |
1 files changed, 74 insertions, 109 deletions
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx index 7c2901ed21..eb0d962d62 100644 --- a/Source/CTest/cmParsePHPCoverage.cxx +++ b/Source/CTest/cmParsePHPCoverage.cxx @@ -16,55 +16,48 @@ */ cmParsePHPCoverage::cmParsePHPCoverage(cmCTestCoverageHandlerContainer& cont, - cmCTest* ctest) - :Coverage(cont), CTest(ctest) + cmCTest* ctest) + : Coverage(cont) + , CTest(ctest) { } bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until) { char c = 0; - while(in.get(c) && c != until) - { - } - if(c != until) - { + while (in.get(c) && c != until) { + } + if (c != until) { return false; - } + } return true; } bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, std::string const& fileName) { - cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector - = this->Coverage.TotalCoverage[fileName]; + cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector = + this->Coverage.TotalCoverage[fileName]; char c; char buf[4]; in.read(buf, 3); buf[3] = 0; - if(strcmp(buf, ";a:") != 0) - { + if (strcmp(buf, ";a:") != 0) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read start of coverage array, found : " - << buf << "\n"); + "failed to read start of coverage array, found : " << buf + << "\n"); return false; - } + } int size = 0; - if(!this->ReadInt(in, size)) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read size "); + if (!this->ReadInt(in, size)) { + cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read size "); return false; - } - if(!in.get(c) && c == '{') - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read open {\n"); + } + if (!in.get(c) && c == '{') { + cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open {\n"); return false; - } - for(int i =0; i < size; i++) - { + } + for (int i = 0; i < size; i++) { this->ReadUntil(in, ':'); int line = 0; this->ReadInt(in, line); @@ -72,19 +65,17 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, // it seems to be 1 based but often times // seems to have a 0'th line. line--; - if(line < 0) - { + if (line < 0) { line = 0; - } + } this->ReadUntil(in, ':'); int value = 0; this->ReadInt(in, value); // make sure the vector is the right size and is // initialized with -1 for each line - while(coverageVector.size() <= static_cast<size_t>(line) ) - { + while (coverageVector.size() <= static_cast<size_t>(line)) { coverageVector.push_back(-1); - } + } // if value is less than 0, set it to zero // TODO figure out the difference between // -1 and -2 in xdebug coverage?? For now @@ -92,21 +83,18 @@ bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in, // CDash expects -1 for non executable code (like comments) // and 0 for uncovered code, and a positive value // for number of times a line was executed - if(value < 0) - { + if (value < 0) { value = 0; - } + } // if unset then set it to value - if(coverageVector[line] == -1) - { + if (coverageVector[line] == -1) { coverageVector[line] = value; - } + } // otherwise increment by value - else - { + else { coverageVector[line] += value; - } } + } return true; } @@ -114,10 +102,9 @@ bool cmParsePHPCoverage::ReadInt(std::istream& in, int& v) { std::string s; char c = 0; - while(in.get(c) && c != ':' && c != ';') - { + while (in.get(c) && c != ':' && c != ';') { s += c; - } + } v = atoi(s.c_str()); return true; } @@ -126,17 +113,14 @@ bool cmParsePHPCoverage::ReadArraySize(std::istream& in, int& size) { char c = 0; in.get(c); - if(c != 'a') - { + if (c != 'a') { return false; - } - if(in.get(c) && c == ':') - { - if(this->ReadInt(in, size)) - { + } + if (in.get(c) && c == ':') { + if (this->ReadInt(in, size)) { return true; - } } + } return false; } @@ -145,110 +129,91 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in) char buf[4]; in.read(buf, 2); buf[2] = 0; - if(strcmp(buf, "s:") != 0) - { + if (strcmp(buf, "s:") != 0) { cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read start of file info found: [" << buf << "]\n"); return false; - } + } char c; int size = 0; - if(this->ReadInt(in, size)) - { + if (this->ReadInt(in, size)) { size++; // add one for null termination - char* s = new char[size+1]; + char* s = new char[size + 1]; // read open quote - if(in.get(c) && c != '"') - { + if (in.get(c) && c != '"') { delete[] s; return false; - } + } // read the string data - in.read(s, size-1); - s[size-1] = 0; + in.read(s, size - 1); + s[size - 1] = 0; std::string fileName = s; - delete [] s; + delete[] s; // read close quote - if(in.get(c) && c != '"') - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read close quote\n" - << "read [" << c << "]\n"); + if (in.get(c) && c != '"') { + cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close quote\n" + << "read [" << c << "]\n"); return false; - } - if(!this->ReadCoverageArray(in, fileName) ) - { + } + if (!this->ReadCoverageArray(in, fileName)) { cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read coverage array for file: " - << fileName << "\n"); + "failed to read coverage array for file: " << fileName + << "\n"); return false; - } - return true; } + return true; + } return false; } - bool cmParsePHPCoverage::ReadPHPData(const char* file) { cmsys::ifstream in(file); - if(!in) - { + if (!in) { return false; - } + } int size = 0; this->ReadArraySize(in, size); char c = 0; in.get(c); - if(c != '{') - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read open array\n"); + if (c != '{') { + cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read open array\n"); return false; - } - for(int i =0; i < size; i++) - { - if(!this->ReadFileInformation(in)) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Failed to read file #" << i << "\n"); + } + for (int i = 0; i < size; i++) { + if (!this->ReadFileInformation(in)) { + cmCTestLog(this->CTest, ERROR_MESSAGE, "Failed to read file #" << i + << "\n"); return false; - } + } in.get(c); - if(c != '}') - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "failed to read close array\n"); + if (c != '}') { + cmCTestLog(this->CTest, ERROR_MESSAGE, "failed to read close array\n"); return false; - } } + } return true; } bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d) { cmsys::Directory dir; - if(!dir.Load(d)) - { + if (!dir.Load(d)) { return false; - } + } size_t numf; unsigned int i; numf = dir.GetNumberOfFiles(); - for (i = 0; i < numf; i++) - { + for (i = 0; i < numf; i++) { std::string file = dir.GetFile(i); - if(file != "." && file != ".." - && !cmSystemTools::FileIsDirectory(file)) - { + if (file != "." && file != ".." && !cmSystemTools::FileIsDirectory(file)) { std::string path = d; path += "/"; path += file; - if(!this->ReadPHPData(path.c_str())) - { + if (!this->ReadPHPData(path.c_str())) { return false; - } } } + } return true; } |