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

Method fsSetDefines

lib/importproject.cpp:213–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211}
212
213void ImportProject::fsSetDefines(FileSettings& fs, std::string defs)
214{
215 while (defs.find(";%(") != std::string::npos) {
216 const std::string::size_type pos1 = defs.find(";%(");
217 const std::string::size_type pos2 = defs.find(';', pos1+1);
218 defs.erase(pos1, pos2 == std::string::npos ? pos2 : (pos2-pos1));
219 }
220 while (defs.find(";;") != std::string::npos)
221 defs.erase(defs.find(";;"),1);
222 while (!defs.empty() && defs[0] == ';')
223 defs.erase(0, 1);
224 while (!defs.empty() && endsWith(defs,';'))
225 defs.pop_back();
226 bool eq = false;
227 for (std::size_t pos = 0; pos < defs.size(); ++pos) {
228 if (defs[pos] == '(' || defs[pos] == '=')
229 eq = true;
230 else if (defs[pos] == ';') {
231 if (!eq) {
232 defs.insert(pos,"=1");
233 pos += 3;
234 }
235 if (pos < defs.size())
236 eq = false;
237 }
238 }
239 if (!eq && !defs.empty())
240 defs += "=1";
241 fs.defines.swap(defs);
242}
243
244static bool simplifyPathWithVariables(std::string &s, std::map<std::string, std::string, cppcheck::stricmp> &variables)
245{

Callers

nothing calls this directly

Calls 6

endsWithFunction · 0.70
findMethod · 0.45
eraseMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected