MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / parseFile

Method parseFile

lib/suppressions.cpp:75–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75std::string SuppressionList::parseFile(std::istream &istr)
76{
77 // Change '\r' to '\n' in the istr
78 std::string filedata;
79 std::string line;
80 while (std::getline(istr, line))
81 filedata += line + "\n";
82 std::replace(filedata.begin(), filedata.end(), '\r', '\n');
83
84 // Parse filedata..
85 std::istringstream istr2(filedata);
86 while (std::getline(istr2, line)) {
87 // Skip empty lines
88 if (line.empty())
89 continue;
90
91 std::string::size_type pos = 0;
92 while (pos < line.size() && std::isspace(line[pos]))
93 ++pos;
94 if (pos == line.size())
95 continue;
96
97 // Skip comments
98 if (line[pos] == '#')
99 continue;
100 if (pos < line.size() - 1 && line[pos] == '/' && line[pos + 1] == '/')
101 continue;
102
103 std::string errmsg(addSuppressionLine(line));
104 if (!errmsg.empty())
105 return errmsg;
106 }
107
108 return "";
109}
110
111
112std::string SuppressionList::parseXmlFile(const char *filename)

Callers 1

parseFromArgsMethod · 0.45

Calls 6

getlineFunction · 0.85
replaceFunction · 0.85
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected