diff options
author | Tobia Tesan | 2017-06-21 18:40:07 +0200 |
---|---|---|
committer | Tobia Tesan | 2017-06-24 11:05:29 +0200 |
commit | c19c10d548b2867bc4fd003fb29ac0017b2bd29d (patch) | |
tree | b2d24cdf5d8d7782594fbc40fe537e78937b1b30 | |
parent | c4ca32453357a6e75567fc75522a8c1c4756dd68 (diff) | |
download | scummvm-rg350-c19c10d548b2867bc4fd003fb29ac0017b2bd29d.tar.gz scummvm-rg350-c19c10d548b2867bc4fd003fb29ac0017b2bd29d.tar.bz2 scummvm-rg350-c19c10d548b2867bc4fd003fb29ac0017b2bd29d.zip |
CREATE_PROJECT: Add fix for nested ifs
This adds a quick fix so that any if blocks nested inside a if block
with an unmet condition are handled with push(false) even if their
condition is satisfied.
For example, without this modification, upon running create_project.exe
--msvc --disable-cloud --enable-libcurl the block inside
ifdef USE_CLOUD
ifdef USE_LIBCURL
...
endif
endif
in backends/module.mk would get evaluated since it was inside
USE_LIBCURL (=1), leading to unpredictable results.
-rw-r--r-- | devtools/create_project/create_project.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/devtools/create_project/create_project.cpp b/devtools/create_project/create_project.cpp index d0cc7da4b2..6715191707 100644 --- a/devtools/create_project/create_project.cpp +++ b/devtools/create_project/create_project.cpp @@ -1770,18 +1770,20 @@ void ProjectProvider::createModuleList(const std::string &moduleDir, const Strin if (std::find(defines.begin(), defines.end(), *i) == defines.end()) shouldInclude.push(false); else - shouldInclude.push(true); + shouldInclude.push(true && shouldInclude.top()); } else if (*i == "ifndef") { if (tokens.size() < 2) error("Malformed ifndef in " + moduleMkFile); ++i; if (std::find(defines.begin(), defines.end(), *i) == defines.end()) - shouldInclude.push(true); + shouldInclude.push(true && shouldInclude.top()); else shouldInclude.push(false); } else if (*i == "else") { - shouldInclude.top() = !shouldInclude.top(); + bool last = shouldInclude.top(); + shouldInclude.pop(); + shouldInclude.push(!last && shouldInclude.top()); } else if (*i == "endif") { if (shouldInclude.size() <= 1) error("endif without ifdef found in " + moduleMkFile); |