[pacman-dev] [PATCH 5/9] conf.c: pass _parse_directive as a callback

Allan McRae allan at archlinux.org
Mon Jul 29 10:17:10 EDT 2013


On 29/07/13 23:19, Andrew Gregory wrote:
> On 07/29/13 at 02:18pm, Allan McRae wrote:
>> On 22/07/13 16:46, Andrew Gregory wrote:
>>> This will allow passing arbitrary key/value handlers.
>>
>> I have now gone through this entire patchset and this is the only patch
>> that confuses me.  What do we gain by doing this?  Are you envisioning
>> having _parse_directive and _parse_hook or something?  Will that be needed?
>>
>> Allan
>>
> 
> Yes, _parse_hook is exactly what I was envisioning.  This patch completely
> decouples the ini parser from the handling of the key/value pairs, making it
> easy to reuse for any file that uses our format simply by passing a different
> key/value handler.  Aside from hooks, I also hope to eventually make the parser
> available to other pacman-related projects so that they can all easily use the
> same config format.
> 

Ah - this all makes sense to me now,  and I think it would have earlier
if _parse_directive had not been such a generic name that I thought it
to be used for every ini parsing.  Of course, looking at the code, it is
not.

I was going to suggest a less generic name, but once _parseconfig is
moved and turned into parse_ini at next, and noting it is in conf.c, it
is really quite clear.

So the patch is all good to me.

Allan




More information about the pacman-dev mailing list