diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 873a7b4ec..d1fbe7446 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -75,18 +75,13 @@ std::vector cmDefinitions::LocalKeys() const } //---------------------------------------------------------------------------- -cmDefinitions cmDefinitions::MakeClosure() const +cmDefinitions cmDefinitions::MakeClosure( + std::list::iterator begin, + std::list::iterator end) { std::set undefined; cmDefinitions closure; - cmDefinitions const* defs = this; - std::list ups; - while(defs) - { - ups.push_back(defs); - defs = defs->Up; - } - closure.MakeClosure(undefined, ups.begin(), ups.end()); + closure.MakeClosure(undefined, begin, end); return closure; } diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 40e053198..67b617069 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -50,7 +50,9 @@ public: /** Compute the set of all defined keys. */ std::vector ClosureKeys() const; - cmDefinitions MakeClosure() const; + static cmDefinitions MakeClosure( + std::list::iterator begin, + std::list::iterator end); private: // String with existence boolean. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8cfb83a57..879709073 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -63,7 +63,15 @@ public: void InitializeDefinitions(cmMakefile* parent) { - this->VarStack.back() = parent->Internal->VarStack.back().MakeClosure(); + std::list defPtrs; + for (std::list::iterator it = + parent->Internal->VarStack.begin(); + it != parent->Internal->VarStack.end(); ++it) + { + defPtrs.push_back(&*it); + } + this->VarStack.back() = cmDefinitions::MakeClosure(defPtrs.begin(), + defPtrs.end()); } const char* GetDefinition(std::string const& name)