Respect order of subconfigs in znc.conf

This commit is contained in:
njhanley
2020-08-30 18:13:39 -04:00
parent 777c6821d8
commit 926d140a47
3 changed files with 28 additions and 16 deletions
+7 -4
View File
@@ -68,6 +68,7 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg) {
std::stringstream stream; \
stream << "Error on line " << uLineNum << ": " << arg; \
sErrorMsg = stream.str(); \
m_SubConfigNameSets.clear(); \
m_SubConfigs.clear(); \
m_ConfigEntries.clear(); \
return false; \
@@ -122,14 +123,16 @@ bool CConfig::Parse(CFile& file, CString& sErrorMsg) {
else
pActiveConfig = &ConfigStack.top().Config;
SubConfig& conf = pActiveConfig->m_SubConfigs[sTag.AsLower()];
SubConfig::const_iterator it = conf.find(sName);
const auto sTagLower = sTag.AsLower();
auto& nameset = pActiveConfig->m_SubConfigNameSets[sTagLower];
if (it != conf.end())
if (nameset.find(sName) != nameset.end())
ERROR("Duplicate entry for tag \"" << sTag << "\" name \""
<< sName << "\".");
conf[sName] = CConfigEntry(myConfig);
nameset.insert(sName);
pActiveConfig->m_SubConfigs[sTagLower].emplace_back(sName,
myConfig);
} else {
if (sValue.empty())
ERROR("Empty block name at begin of block.");