Commit a0612536 authored by jan.koester's avatar jan.koester
Browse files

bugfix

parent 4714416a
Loading
Loading
Loading
Loading
+18 −0
Changes for parser.cpp: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -785,7 +785,25 @@ void Parser::handle_include(const std::string& args, Makefile& mf, bool optional
        if (file.is_open()) {
            std::string content((std::istreambuf_iterator<char>(file)),
                                 std::istreambuf_iterator<char>());
            // An included makefile is parsed in its own conditional context and
            // must have balanced conditionals; it may not close a conditional
            // opened by the parent. parse_string() resets cond_stack_/define
            // state, so save and restore the parent's parsing state around the
            // recursive parse to keep the enclosing conditional nesting intact.
            auto saved_cond = cond_stack_;
            bool saved_in_define = in_define_;
            std::string saved_dname = define_name_, saved_dop = define_op_;
            std::vector<std::string> saved_dbody = define_body_;
            std::string saved_base = mf.base_dir;

            parse_string(content, mf);

            cond_stack_ = saved_cond;
            in_define_ = saved_in_define;
            define_name_ = saved_dname;
            define_op_ = saved_dop;
            define_body_ = saved_dbody;
            mf.base_dir = saved_base;
        }
    }
}