| 56 | } |
| 57 | |
| 58 | void cmParseMumpsCoverage::InitializeMumpsFile(std::string& file) |
| 59 | { |
| 60 | // initialize the coverage information for a given mumps file |
| 61 | cmsys::ifstream in(file.c_str()); |
| 62 | if (!in) { |
| 63 | return; |
| 64 | } |
| 65 | std::string line; |
| 66 | cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector = |
| 67 | this->Coverage.TotalCoverage[file]; |
| 68 | if (!cmSystemTools::GetLineFromStream(in, line)) { |
| 69 | return; |
| 70 | } |
| 71 | // first line of a .m file can never be run |
| 72 | coverageVector.push_back(-1); |
| 73 | while (cmSystemTools::GetLineFromStream(in, line)) { |
| 74 | // putting in a 0 for a line means it is executable code |
| 75 | // putting in a -1 for a line means it is not executable code |
| 76 | int val = -1; // assume line is not executable |
| 77 | bool found = false; |
| 78 | std::string::size_type i = 0; |
| 79 | // (1) Search for the first whitespace or semicolon character on a line. |
| 80 | // This will skip over labels if the line starts with one, or will simply |
| 81 | // be the first character on the line for non-label lines. |
| 82 | for (; i < line.size(); ++i) { |
| 83 | if (line[i] == ' ' || line[i] == '\t' || line[i] == ';') { |
| 84 | found = true; |
| 85 | break; |
| 86 | } |
| 87 | } |
| 88 | if (found) { |
| 89 | // (2) If the first character found above is whitespace or a period |
| 90 | // then continue the search for the first following non-whitespace |
| 91 | // character. |
| 92 | if (line[i] == ' ' || line[i] == '\t') { |
| 93 | while (i < line.size() && |
| 94 | (line[i] == ' ' || line[i] == '\t' || line[i] == '.')) { |
| 95 | i++; |
| 96 | } |
| 97 | } |
| 98 | // (3) If the character found is not a semicolon then the line counts for |
| 99 | // coverage. |
| 100 | if (i < line.size() && line[i] != ';') { |
| 101 | val = 0; |
| 102 | } |
| 103 | } |
| 104 | coverageVector.push_back(val); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | bool cmParseMumpsCoverage::LoadPackages(std::string const& d) |
| 109 | { |
no test coverage detected