Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/simpleini.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <brofield@users.noreply.github.com>2020-06-16 20:01:11 +0300
committerunknown <brofield@users.noreply.github.com>2020-06-16 20:01:11 +0300
commit592b165f35d8608b957ff05c4d8caacdbb501e95 (patch)
tree9228fb84573d55feda2a8b803256983041fb89dc /SimpleIni.h
parentfa3f25fb78fce5b5f8a509e5dfee0defc12b82ed (diff)
Fix problem where items without a section (e.g. the empty section) were added into whichever section they were created after.
Diffstat (limited to 'SimpleIni.h')
-rw-r--r--SimpleIni.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/SimpleIni.h b/SimpleIni.h
index a09a6cc..843a73f 100644
--- a/SimpleIni.h
+++ b/SimpleIni.h
@@ -2424,6 +2424,19 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::Save(
oSections.sort(typename Entry::LoadOrder());
#endif
+ // if there is an empty section name, then it must be written out first
+ // regardless of the load order
+ typename TNamesDepend::iterator is = oSections.begin();
+ for (; is != oSections.end(); ++is) {
+ if (!*is->pItem) {
+ // move the empty section name to the front of the section list
+ if (is != oSections.begin()) {
+ oSections.splice(oSections.begin(), oSections, is, std::next(is));
+ }
+ break;
+ }
+ }
+
// write the file comment if we have one
bool bNeedNewLine = false;
if (m_pFileComment) {