Hiho!
If you take the example program for list_config_entries
1 | int i, n; |
2 | char const **sections = NULL; |
3 | char const **entries = NULL; |
4 | |
5 | n = list_config_sections(§ions); |
6 | /* loop through all section names */ |
7 | for (i = 0; i < n; i++) |
8 | { |
9 | int j, m; |
10 | printf("%s\n", sections<i>); |
11 | m = list_config_entries(sections<i>, &entries); |
12 | /* loop through all entries in the section */ |
13 | for (j = 0; j < m; j++) |
14 | { |
15 | printf(" %s=\"%s\"\n", entries[j], get_config_string( |
16 | sections<i>, entries[j], "-")); |
17 | } |
18 | } |
19 | free_config_entries(§ions); |
20 | free_config_entries(&entries); |
and feed it with a config file like this:
value0=foo value1=bar
You won't see anything since the "global" section is not returned at all. I'd suggest to return global settings belonging to a section named "" or a NULL pointer.
Also, if use a section name that contains a space, the section will not be loaded at all. This should either be pointed out in the documentation or changed in the implementation.
If you take the example program for list_config_entries and feed it with a config file like this:
value0=foo
value1=bar
You won't see anything since the "global" section is not returned at all. I'd suggest to return global settings belonging to a section named "" or a NULL pointer.
Another way to fix it would be if the example would first use list_config_entries to get all global entries, and only then loop through the sections. This would not require code changes, just modifying the example.
Also, if use a section name that contains a space, the section will not be loaded at all. This should either be pointed out in the documentation or changed in the implementation.
That's not specific to list_config_sections though.
Elias: I remember telling you about the bug in that example (where free_config_sections is called outside the loop where it should be called)... Was this fix only in SVN?
It should work like that, as it uses realloc internally - so it's enough to free it outside. You fixed something else though:
r7812 | elias | 2007-04-04 15:11:04 +0200 (Wed, 04 Apr 2007) | 1 line
Ryan Patterson fixed a crash in free_config_entries.
That's not specific to list_config_sections though.
Yep, that's why I specified two problems in the topic name
this would not require code changes, just modifying the example.
That might be an idea as well
Yep, that's why I specified two problems in the topic name
Ah, so you expected me to read the topic
That might be an idea as well
------------------------------------------------------------------------
r7909 | elias | 2007-06-10 17:59:07 +0200 (Sun, 10 Jun 2007) | 4 lines
Fixed two problems pointed out by spellcaster on allegro.cc:
- Mention in the docs that config section and variable names cannot contain spaces.
- Fixed the example for list_config_entries to really display all entries, even those not in any section.
------------------------------------------------------------------------