--- a/src/lib/INIReader.cpp Mon Nov 23 16:25:39 2020 +0100
+++ b/src/lib/INIReader.cpp Mon Nov 23 17:56:16 2020 +0100
@@ -39,7 +39,7 @@
std::regex whitespacePattrern("\\s*");
std::regex commentPattrern("\\s*(;|#)\\s*(.*)");
- std::regex sectionPattrern("\\s*\\[\\s*([^\\]]+)\\s*\\]\\s*((;|#)\\s*(.*))?");
+ std::regex sectionPattrern("\\s*\\[\\s*([^\\]]+)\\s*\\]\\s*(\\[\\s*([^\\]]+)\\s*\\])?\\s*((;|#)\\s*(.*))?");
std::regex entryQuotesPattrern(/***/"\\s*(([^=\\]]+?[^=\\s\\]]*)(\\[([^\\]]+)\\])?)\\s*=\\s*\"([^']+)\"\\s*((;|#)\\s*(.*))?");
std::regex entryApostrophesPattrern("\\s*(([^=\\]]+?[^=\\s\\]]*)(\\[([^\\]]+)\\])?)\\s*=\\s*'([^']+)'\\s*((;|#)\\s*(.*))?");
std::regex entryPlainPattrern("\\s*(([^=\\]]+?[^=\\s\\]]*)(\\[([^\\]]+)\\])?)\\s*=\\s*(.*)");
@@ -73,7 +73,11 @@
event.lineNumber = lineNumber;
event.eventNumber = ++eventNumber;
event.name = match[1];
- event.comment = match[4];
+ event.comment = match[6];
+ // event.tag = match[3];
+ // KDE uses some weird INI dialect that allows [section][x] syntax where „x“ is kind of „tag“ that signalizes some properties of given section.
+ // see <https://userbase.kde.org/KDE_System_Administration/Configuration_Files>, „[$i]“ means that the section is „locked“
+ // We may emit this information somehow later, but for now, it is just ignored.
for (INIContentHandler* handler : handlers) handler->startSection(event);
} else if (std::regex_match(line, match, entryQuotesPattrern) || std::regex_match(line, match, entryApostrophesPattrern) || std::regex_match(line, match, entryPlainPattrern)) {
INIContentHandler::EntryEvent event;
@@ -96,6 +100,7 @@
// TODO: support also quoted or multiline keys?
// TODO: support also escaped characters
// TODO: support also Java .properties and manifest.mf formats?
+ // TODO: support also quoted sections ["qoted section"] – useful for hierarchy (the path element may contain the separator character)
// TODO: support also nested sections – hierarchy
// TODO: support also nested keys e.g. key.sub.subsub.subsubsub=value – translate them to nested sections
// TODO: support also option for alternative key-value separator (: instead of =)