# HG changeset patch # User František Kučera # Date 1606150615 -3600 # Node ID be61125d8ed1385893cc8063656e5284d5da0976 # Parent 83b23480d41ff58fc59d8001c72b5edd1ecd7234 partial support of KDE syntax: [section][] diff -r 83b23480d41f -r be61125d8ed1 nbproject/configurations.xml --- a/nbproject/configurations.xml Mon Nov 23 17:23:16 2020 +0100 +++ b/nbproject/configurations.xml Mon Nov 23 17:56:55 2020 +0100 @@ -98,11 +98,13 @@ true - + + + diff -r 83b23480d41f -r be61125d8ed1 src/lib/INIReader.cpp --- a/src/lib/INIReader.cpp Mon Nov 23 17:23:16 2020 +0100 +++ b/src/lib/INIReader.cpp Mon Nov 23 17:56:55 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 , „[$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 =)