From b66875d8adced2b398d10ca7ffa54504534162d6 Mon Sep 17 00:00:00 2001 From: spx Date: Fri, 20 Jul 2012 02:33:52 -0700 Subject: [PATCH] Additional change to 720ed17: Now the sections that the included file has are placed to the last position if @include is placed on the last section in the original file. --- Library/ConfigParser.cpp | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Library/ConfigParser.cpp b/Library/ConfigParser.cpp index ed23df60..b61adb43 100644 --- a/Library/ConfigParser.cpp +++ b/Library/ConfigParser.cpp @@ -1326,13 +1326,24 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection if (resetInsertPos) { - for (auto it = m_Sections.cbegin(); it != m_Sections.cend(); ++it) + auto jt = iter; + if (++jt == sections.end()) // Special case: @include was used in the last section of the current file { - if (_wcsicmp((*it).c_str(), sectionName) == 0) + // Set the insertion place to the last + m_SectionInsertPos = m_Sections.end(); + resetInsertPos = false; + } + else + { + // Find the appropriate insertion place + for (auto it = m_Sections.cbegin(); it != m_Sections.cend(); ++it) { - m_SectionInsertPos = ++it; - resetInsertPos = false; - break; + if (_wcsicmp((*it).c_str(), sectionName) == 0) + { + m_SectionInsertPos = ++it; + resetInsertPos = false; + break; + } } } }