| 242 | } |
| 243 | |
| 244 | static bool simplifyPathWithVariables(std::string &s, std::map<std::string, std::string, cppcheck::stricmp> &variables) |
| 245 | { |
| 246 | std::set<std::string, cppcheck::stricmp> expanded; |
| 247 | std::string::size_type start = 0; |
| 248 | while ((start = s.find("$(")) != std::string::npos) { |
| 249 | const std::string::size_type end = s.find(')',start); |
| 250 | if (end == std::string::npos) |
| 251 | break; |
| 252 | const std::string var = s.substr(start+2,end-start-2); |
| 253 | if (expanded.find(var) != expanded.end()) |
| 254 | break; |
| 255 | expanded.insert(var); |
| 256 | auto it1 = utils::as_const(variables).find(var); |
| 257 | // variable was not found within defined variables |
| 258 | if (it1 == variables.end()) { |
| 259 | const char *envValue = std::getenv(var.c_str()); |
| 260 | if (!envValue) { |
| 261 | //! \todo generate a debug/info message about undefined variable |
| 262 | break; |
| 263 | } |
| 264 | variables[var] = std::string(envValue); |
| 265 | it1 = variables.find(var); |
| 266 | } |
| 267 | s.replace(start, end - start + 1, it1->second); |
| 268 | } |
| 269 | if (s.find("$(") != std::string::npos) |
| 270 | return false; |
| 271 | s = Path::simplifyPath(std::move(s)); |
| 272 | return true; |
| 273 | } |
| 274 | |
| 275 | void ImportProject::fsSetIncludePaths(FileSettings& fs, const std::string &basepath, const std::list<std::string> &in, std::map<std::string, std::string, cppcheck::stricmp> &variables) |
| 276 | { |
no test coverage detected