Merge pull request #837 from nablaa/master

Fixes preprocessor regression causing hang
This commit is contained in:
Daniel Marjamäki 2016-10-11 23:31:49 +02:00 committed by GitHub
commit e0f9171127
2 changed files with 13 additions and 0 deletions

View File

@ -217,6 +217,10 @@ static std::string readcondition(const simplecpp::Token *iftok, const std::set<s
static bool hasDefine(const std::string &userDefines, const std::string &cfg) static bool hasDefine(const std::string &userDefines, const std::string &cfg)
{ {
if (cfg.empty()) {
return false;
}
std::string::size_type pos = 0; std::string::size_type pos = 0;
while (pos < userDefines.size()) { while (pos < userDefines.size()) {
pos = userDefines.find(cfg, pos); pos = userDefines.find(cfg, pos);

View File

@ -224,6 +224,7 @@ private:
TEST_CASE(getConfigsU4); TEST_CASE(getConfigsU4);
TEST_CASE(getConfigsU5); TEST_CASE(getConfigsU5);
TEST_CASE(getConfigsU6); TEST_CASE(getConfigsU6);
TEST_CASE(getConfigsU7);
TEST_CASE(validateCfg); TEST_CASE(validateCfg);
@ -2121,6 +2122,14 @@ private:
ASSERT_EQUALS("\nX=0\n", getConfigsStr(filedata)); ASSERT_EQUALS("\nX=0\n", getConfigsStr(filedata));
} }
void getConfigsU7() {
const char code[] = "#ifndef Y\n"
"#else\n"
"#endif\n";
ASSERT_EQUALS("\nY\n", getConfigsStr(code, "-DX"));
}
void validateCfg() { void validateCfg() {
Settings settings; Settings settings;
Preprocessor preprocessor(settings, this); Preprocessor preprocessor(settings, this);