[icinga-checkins] icinga.org: icinga2/master: Fix: ConfigItem types and names are not case-insensitive

git at icinga.org git at icinga.org
Wed May 8 10:46:58 CEST 2013


Module: icinga2
Branch: master
Commit: b4fa556ac66b6eadfe60443e521d285516e87059
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=b4fa556ac66b6eadfe60443e521d285516e87059

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Wed May  8 10:46:50 2013 +0200

Fix: ConfigItem types and names are not case-insensitive

Fixes #4044

---

 lib/base/qstring.h                 |   15 +++++++++++++++
 lib/config/configcompilercontext.h |    4 ++--
 lib/config/configitem.h            |    2 +-
 3 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/lib/base/qstring.h b/lib/base/qstring.h
index e085045..395f56c 100644
--- a/lib/base/qstring.h
+++ b/lib/base/qstring.h
@@ -24,6 +24,7 @@
 #include <boost/range/iterator.hpp>
 #include <ostream>
 #include <istream>
+#include <utility>
 
 namespace icinga {
 
@@ -155,6 +156,20 @@ struct string_iless : std::binary_function<String, String, bool>
 	}
 };
 
+struct pair_string_iless : std::binary_function<std::pair<String, String>, std::pair<String, String>, bool>
+{
+	bool operator()(const std::pair<String, String>& p1, const std::pair<String, String>& p2) const
+	{
+		if (string_iless()(p1.first, p2.first))
+			return true;
+
+		if (string_iless()(p2.first, p1.first))
+			return false;
+
+		return string_iless()(p1.second, p2.second);
+	}
+};
+
 }
 
 namespace boost
diff --git a/lib/config/configcompilercontext.h b/lib/config/configcompilercontext.h
index f34966e..8852bcf 100644
--- a/lib/config/configcompilercontext.h
+++ b/lib/config/configcompilercontext.h
@@ -82,9 +82,9 @@ private:
         int m_Flags;
 
 	std::vector<ConfigItem::Ptr> m_Items;
-        std::map<std::pair<String, String>, ConfigItem::Ptr> m_ItemsMap;
+        std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> m_ItemsMap;
 
-        std::map<String, shared_ptr<ConfigType> > m_Types;
+        std::map<String, shared_ptr<ConfigType>, string_iless> m_Types;
 
         std::vector<ConfigCompilerError> m_Errors;
 
diff --git a/lib/config/configitem.h b/lib/config/configitem.h
index f91aef1..8b9e8a2 100644
--- a/lib/config/configitem.h
+++ b/lib/config/configitem.h
@@ -99,7 +99,7 @@ private:
 
 	static boost::mutex m_Mutex;
 
-	typedef std::map<std::pair<String, String>, ConfigItem::Ptr> ItemMap;
+	typedef std::map<std::pair<String, String>, ConfigItem::Ptr, pair_string_iless> ItemMap;
 	static ItemMap m_Items; /**< All registered configuration items. */
 
 	static ConfigItem::Ptr GetObjectUnlocked(const String& type,





More information about the icinga-checkins mailing list