From c19c10d548b2867bc4fd003fb29ac0017b2bd29d Mon Sep 17 00:00:00 2001 From: Tobia Tesan Date: Wed, 21 Jun 2017 18:40:07 +0200 Subject: 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. --- devtools/create_project/create_project.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'devtools/create_project') 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); -- cgit v1.2.3