[augeas-devel] [PATCH] Write last created node in /augeas/tree/last_created for tree_create and tree_insert

David Lutterkort dlutter at redhat.com
Fri Aug 8 21:55:23 UTC 2008


On Fri, 2008-08-08 at 22:57 +0200, Raphaël Pinson wrote:
> 
> 
> On Fri, Aug 8, 2008 at 10:12 PM, David Lutterkort <dlutter at redhat.com>
> wrote:

>         Yes, I think that would be the cleanest solution: tree_insert
>         should
>         become
>         
>                int tree_insert(struct tree **tree, const char *path,
>         const char *label,
>                                int before, struct path **node)

Thinking about this more, this is pretty ugly. I'd prefer it if
aug_insert actually calls make_path and then passes that to tree_insert,
which sets the path to the newly created node before returning, so that
tree_insert ahs the signature

        int tree_insert(struct tree **tree, struct path *path, const char *label,
                        int before)


> Yes, that would work here. But how about the tree_create function?
> tree_create is called from tree_set and aug_mv (and will be called
> from aug_cp and it's done). 

You have aug_cp working ? Excellent .. looking forward to the patch ;)

> Should each of aug_set, aug_mv and aug_cp deal with the node and both
> tree_create and tree_set calls be changed?

tree_create already sets a struct path up, so only tree_set needs to be
modified; since that is also used from builtin.c, it's probably easiest
to split the current tree_set into a tree_set (same signature as curent
version) and a tree_set_path with signature

        struct tree *tree_set_path(struct tree *root, struct path *path, const char *value)
        
that is called from aug_set.
        
I'd also split all that cruft I had for aug_insert into a static utility
function, something like 'aug_set_last_created(struct augeas *aug,
struct path *path)'

David





More information about the augeas-devel mailing list