From 9bc8e3bae31133cecfd9693d13a4272b23adf2b0 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Fri, 31 Oct 2014 21:54:01 -0400 Subject: [PATCH] CLI - Corrected lookup for existing entities. --- src/CLI.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/CLI.cpp b/src/CLI.cpp index f27d005c9..760d7a1b6 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -243,8 +243,18 @@ void CLI::alias (const std::string& name, const std::string& value) //////////////////////////////////////////////////////////////////////////////// void CLI::entity (const std::string& category, const std::string& name) { - if (_entities.find (category) == _entities.end ()) - _entities.insert (std::pair (category, name)); + // Find the category. + std::pair ::const_iterator, std::multimap ::const_iterator> c; + c = _entities.equal_range (category); + + // Walk the list of entities for category. + std::multimap ::const_iterator e; + for (e = c.first; e != c.second; ++e) + if (e->second == name) + return; + + // The category/name pair was not found, therefore add it. + _entities.insert (std::pair (category, name)); } ////////////////////////////////////////////////////////////////////////////////