summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmParseDelphiCoverage.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/CTest/cmParseDelphiCoverage.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/CTest/cmParseDelphiCoverage.cxx')
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx217
1 files changed, 94 insertions, 123 deletions
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index 09c4f02..d20b16a 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -8,93 +8,76 @@
#include <stdio.h>
#include <stdlib.h>
-
class cmParseDelphiCoverage::HTMLParser
{
public:
typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
- FileLinesType;
+ FileLinesType;
HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
- : CTest(ctest), Coverage(cont)
- {
- }
+ : CTest(ctest)
+ , Coverage(cont)
+ {
+ }
- virtual ~HTMLParser()
- {
- }
+ virtual ~HTMLParser() {}
- bool initializeDelphiFile(const std::string filename,
- cmParseDelphiCoverage::HTMLParser::FileLinesType &coverageVector)
- {
+ bool initializeDelphiFile(
+ const std::string filename,
+ cmParseDelphiCoverage::HTMLParser::FileLinesType& coverageVector)
+ {
std::string line;
size_t comPos;
size_t semiPos;
- bool blockComFlag= false;
- bool lineComFlag= false;
+ bool blockComFlag = false;
+ bool lineComFlag = false;
std::vector<std::string> beginSet;
cmsys::ifstream in(filename.c_str());
- if(!in)
- {
+ if (!in) {
return false;
- }
- while(cmSystemTools::GetLineFromStream(in, line))
- {
- lineComFlag=false;
+ }
+ while (cmSystemTools::GetLineFromStream(in, line)) {
+ lineComFlag = false;
// Unique cases found in lines.
size_t beginPos = line.find("begin");
- //Check that the begin is the first non-space string on the line
- if( (beginPos == line.find_first_not_of(' ')) && beginPos != line.npos )
- {
+ // Check that the begin is the first non-space string on the line
+ if ((beginPos == line.find_first_not_of(' ')) && beginPos != line.npos) {
beginSet.push_back("begin");
coverageVector.push_back(-1);
continue;
- }
- else if(line.find('{') != line.npos)
- {
- blockComFlag=true;
- }
- else if(line.find('}') != line.npos)
- {
- blockComFlag=false;
+ } else if (line.find('{') != line.npos) {
+ blockComFlag = true;
+ } else if (line.find('}') != line.npos) {
+ blockComFlag = false;
coverageVector.push_back(-1);
continue;
- }
- else if((line.find("end;") != line.npos)
- && !beginSet.empty())
- {
+ } else if ((line.find("end;") != line.npos) && !beginSet.empty()) {
beginSet.pop_back();
coverageVector.push_back(-1);
continue;
- }
+ }
// This checks for comments after lines of code, finding the
// comment symbol after the ending semicolon.
comPos = line.find("//");
- if(comPos != line.npos)
- {
- semiPos= line.find(';');
- if(comPos < semiPos)
- {
- lineComFlag=true;
- }
+ if (comPos != line.npos) {
+ semiPos = line.find(';');
+ if (comPos < semiPos) {
+ lineComFlag = true;
}
- //Based up what was found, add a line to the coverageVector
- if(!beginSet.empty() && line != "" && !blockComFlag
- && !lineComFlag)
- {
+ }
+ // Based up what was found, add a line to the coverageVector
+ if (!beginSet.empty() && line != "" && !blockComFlag && !lineComFlag) {
coverageVector.push_back(0);
- }
- else
- {
+ } else {
coverageVector.push_back(-1);
- }
}
- return true;
}
+ return true;
+ }
bool ParseFile(const char* file)
- {
- std::string line=file;
+ {
+ std::string line = file;
std::string lineresult;
std::string lastroutine;
std::string filename;
@@ -117,28 +100,25 @@ public:
* to see if it ends in '.pas'. If it can't be found,
* exit the function.
*/
- while(true)
- {
- lastoffset = line.find('(',pos);
- if(lastoffset==line.npos)
- {
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- endnamepos << "File not found " << lastoffset << std::endl,
- this->Coverage.Quiet);
+ while (true) {
+ lastoffset = line.find('(', pos);
+ if (lastoffset == line.npos) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, endnamepos
+ << "File not found " << lastoffset << std::endl,
+ this->Coverage.Quiet);
return false;
- }
- endnamepos = line.find(')',lastoffset);
- filename = line.substr(lastoffset+1,
- (endnamepos-1)-lastoffset);
- if(filename.find(".pas") != filename.npos)
- {
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Coverage found for file: " << filename << std::endl,
- this->Coverage.Quiet);
+ }
+ endnamepos = line.find(')', lastoffset);
+ filename = line.substr(lastoffset + 1, (endnamepos - 1) - lastoffset);
+ if (filename.find(".pas") != filename.npos) {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Coverage found for file: " << filename
+ << std::endl,
+ this->Coverage.Quiet);
break;
- }
- pos = lastoffset+1;
}
+ pos = lastoffset + 1;
+ }
/*
* Glob through the source directory for the
* file found above
@@ -149,32 +129,29 @@ public:
std::string glob = Coverage.SourceDir + "*/" + filename;
gl.FindFiles(glob);
std::vector<std::string> const& files = gl.GetFiles();
- if(files.empty())
- {
+ if (files.empty()) {
/*
* If that doesn't find any matching files
* return a failure.
*/
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Unable to find file matching" << glob << std::endl,
- this->Coverage.Quiet);
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Unable to find file matching" << glob << std::endl,
+ this->Coverage.Quiet);
return false;
- }
- FileLinesType& coverageVector =
- this->Coverage.TotalCoverage[files[0]];
+ }
+ FileLinesType& coverageVector = this->Coverage.TotalCoverage[files[0]];
/*
* Initialize the file to have all code between 'begin' and
* 'end' tags marked as executable
*/
- this->initializeDelphiFile(files[0],coverageVector);
+ this->initializeDelphiFile(files[0], coverageVector);
cmsys::ifstream in(file);
- if(!in)
- {
+ if (!in) {
return false;
- }
+ }
/*
* Now read the HTML file, looking for the lines that have an
@@ -188,67 +165,61 @@ public:
*
*/
- while( cmSystemTools::GetLineFromStream(in, line))
- {
- if(line.find("inline") == line.npos)
- {
+ while (cmSystemTools::GetLineFromStream(in, line)) {
+ if (line.find("inline") == line.npos) {
continue;
- }
+ }
lastoffset = line.find("class=");
- endcovpos = line.find(">",lastoffset);
- lineresult = line.substr(lastoffset+7,(endcovpos-8)-lastoffset);
-
- if(lineresult == "covered")
- {
- afterLineNum = line.find('<',endcovpos+5);
- filelineoffset= line.substr(endcovpos+5,
- afterLineNum-(endcovpos+5));
- coverageVector[atoi(filelineoffset.c_str())-1] = 1;
- }
+ endcovpos = line.find(">", lastoffset);
+ lineresult = line.substr(lastoffset + 7, (endcovpos - 8) - lastoffset);
+
+ if (lineresult == "covered") {
+ afterLineNum = line.find('<', endcovpos + 5);
+ filelineoffset =
+ line.substr(endcovpos + 5, afterLineNum - (endcovpos + 5));
+ coverageVector[atoi(filelineoffset.c_str()) - 1] = 1;
}
- return true;
}
+ return true;
+ }
-
- private:
- cmCTest* CTest;
- cmCTestCoverageHandlerContainer& Coverage;
+private:
+ cmCTest* CTest;
+ cmCTestCoverageHandlerContainer& Coverage;
};
cmParseDelphiCoverage::cmParseDelphiCoverage(
- cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
- :Coverage(cont), CTest(ctest)
- {
- }
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ : Coverage(cont)
+ , CTest(ctest)
+{
+}
bool cmParseDelphiCoverage::LoadCoverageData(
const std::vector<std::string> files)
- {
+{
size_t i;
std::string path;
size_t numf = files.size();
- for (i = 0; i < numf; i++)
- {
+ for (i = 0; i < numf; i++) {
path = files[i];
- cmCTestOptionalLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
- "Reading HTML File " << path << std::endl, this->Coverage.Quiet);
- if(cmSystemTools::GetFilenameLastExtension(path) == ".html")
- {
- if(!this->ReadDelphiHTML(path.c_str()))
- {
+ cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Reading HTML File " << path << std::endl,
+ this->Coverage.Quiet);
+ if (cmSystemTools::GetFilenameLastExtension(path) == ".html") {
+ if (!this->ReadDelphiHTML(path.c_str())) {
return false;
- }
}
}
- return true;
}
+ return true;
+}
bool cmParseDelphiCoverage::ReadDelphiHTML(const char* file)
- {
- cmParseDelphiCoverage::HTMLParser
- parser(this->CTest, this->Coverage);
+{
+ cmParseDelphiCoverage::HTMLParser parser(this->CTest, this->Coverage);
parser.ParseFile(file);
return true;
- }
+}