<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>list_config_sections not working correctly and section name problem</title>
		<link>http://www.allegro.cc/forums/view/591831</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 10 Jun 2007 21:00:17 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hiho!</p><p>If you take the example program for list_config_entries</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">int</span> i, n<span class="k2">;</span></td></tr><tr><td class="number">2</td><td>   <span class="k1">char</span> <span class="k1">const</span> <span class="k3">*</span><span class="k3">*</span>sections <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">3</td><td>   <span class="k1">char</span> <span class="k1">const</span> <span class="k3">*</span><span class="k3">*</span>entries <span class="k3">=</span> NULL<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td>   n <span class="k3">=</span> <a href="http://www.allegro.cc/manual/list_config_sections" target="_blank"><span class="a">list_config_sections</span></a><span class="k2">(</span><span class="k3">&amp;</span>sections<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>   <span class="c">/* loop through all section names */</span></td></tr><tr><td class="number">7</td><td>   <span class="k1">for</span> <span class="k2">(</span>i <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> i <span class="k3">&lt;</span> n<span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">8</td><td>   <span class="k2">{</span></td></tr><tr><td class="number">9</td><td>      <span class="k1">int</span> j, m<span class="k2">;</span></td></tr><tr><td class="number">10</td><td>      <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, sections<span class="k3">&lt;</span>i&gt;<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>      m <span class="k3">=</span> <a href="http://www.allegro.cc/manual/list_config_entries" target="_blank"><span class="a">list_config_entries</span></a><span class="k2">(</span>sections<span class="k3">&lt;</span>i&gt;, <span class="k3">&amp;</span>entries<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>      <span class="c">/* loop through all entries in the section */</span></td></tr><tr><td class="number">13</td><td>      <span class="k1">for</span> <span class="k2">(</span>j <span class="k3">=</span> <span class="n">0</span><span class="k2">;</span> j <span class="k3">&lt;</span> m<span class="k2">;</span> j<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span></td></tr><tr><td class="number">14</td><td>      <span class="k2">{</span></td></tr><tr><td class="number">15</td><td>          <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">" %s=\"%s\"\n"</span>, entries<span class="k2">[</span>j<span class="k2">]</span>, <a href="http://www.allegro.cc/manual/get_config_string" target="_blank"><span class="a">get_config_string</span></a><span class="k2">(</span></td></tr><tr><td class="number">16</td><td>             sections<span class="k3">&lt;</span>i&gt;, entries<span class="k2">[</span>j<span class="k2">]</span>, <span class="s">"-"</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>      <span class="k2">}</span></td></tr><tr><td class="number">18</td><td>   <span class="k2">}</span></td></tr><tr><td class="number">19</td><td>   <a href="http://www.allegro.cc/manual/free_config_entries" target="_blank"><span class="a">free_config_entries</span></a><span class="k2">(</span><span class="k3">&amp;</span>sections<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">20</td><td>   <a href="http://www.allegro.cc/manual/free_config_entries" target="_blank"><span class="a">free_config_entries</span></a><span class="k2">(</span><span class="k3">&amp;</span>entries<span class="k2">)</span><span class="k2">;</span></td></tr></tbody></table></div></div><p>

and feed it with a config file like this:</p><div class="source-code snippet"><div class="inner"><pre>value0<span class="k3">=</span>foo
value1<span class="k3">=</span>bar
</pre></div></div><p>
You won&#39;t see anything since the &quot;global&quot; section is not returned at all. I&#39;d suggest to return global settings belonging to a section named &quot;&quot; or a NULL pointer.</p><p>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.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spellcaster)</author>
		<pubDate>Sun, 10 Jun 2007 18:25:21 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
If you take the example program for list_config_entries and feed it with a config file like this:</p><p>value0=foo<br />value1=bar</p><p>You won&#39;t see anything since the &quot;global&quot; section is not returned at all. I&#39;d suggest to return global settings belonging to a section named &quot;&quot; or a NULL pointer.
</p></div></div><p>

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.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
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.
</p></div></div><p>

That&#39;s not specific to list_config_sections though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 10 Jun 2007 18:48:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>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?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (CGamesPlay)</author>
		<pubDate>Sun, 10 Jun 2007 20:09:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It should work like that, as it uses realloc internally - so it&#39;s enough to free it outside. You fixed something else though:
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
r7812 | elias | 2007-04-04 15:11:04 +0200 (Wed, 04 Apr 2007) | 1 line</p><p>Ryan Patterson fixed a crash in free_config_entries.
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 10 Jun 2007 20:13:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That&#39;s not specific to list_config_sections though.
</p></div></div><p>
Yep, that&#39;s why I specified two problems in the topic name <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
this would not require code changes, just modifying the example.
</p></div></div><p>
That might be an idea as well <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (spellcaster)</author>
		<pubDate>Sun, 10 Jun 2007 20:24:53 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Yep, that&#39;s why I specified two problems in the topic name <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div></div><p>
Ah, so you expected me to read the topic <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" /></p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
That might be an idea as well <img src="http://www.allegro.cc/forums/smileys/wink.gif" alt=";)" />
</p></div></div><p>
</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
------------------------------------------------------------------------<br />r7909 | elias | 2007-06-10 17:59:07 +0200 (Sun, 10 Jun 2007) | 4 lines</p><p>Fixed two problems pointed out by spellcaster on allegro.cc:<br />- Mention in the docs that config section and variable names cannot contain spaces.<br />- Fixed the example for list_config_entries to really display all entries, even those not in any section.</p><p>------------------------------------------------------------------------
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Sun, 10 Jun 2007 21:00:17 +0000</pubDate>
	</item>
</rss>
