compuphase / minIni

A small and portable INI file library with read/write support
http://www.compuphase.com/minini.htm
Other
371 stars 113 forks source link

Improve support for "subsections" #2

Open tbeu opened 7 years ago

tbeu commented 7 years ago

If an INI file contains a "subsection", then in the INI_CALLBACK handler the section name is kind of unexpected. For example in the simple example

[section]
[[subsection]]
key = value

it is [subsection, thus it seems minIni looks for the first right bracket.

tbeu commented 7 years ago

A further enhancement would be if the INI_CALLBACK handler is first called with section set to section and key set to NULL, and in the subsequent call with section set to subsection and key set to key. This way the application would actually be notified about the section hierarchy.

compuphase commented 7 years ago

If you need subsections, consider this syntax:

[section] key=abc [section:subsection] key=def

Etcetera. This convention can be used with the ini_putX() functions too.

tbeu commented 7 years ago

The [[subsection]] syntax is used by Py Config which I have no chance to influence.

The simplest idea ist to check for the last closing bracket instead of the first one. What do you think?