[augeas-devel] [PATCH] Add aug_rename to rename node labels without moving them in the tree.

Raphaël Pinson raphael.pinson at camptocamp.com
Wed Aug 1 18:17:54 UTC 2012


On Wed, Aug 1, 2012 at 7:57 PM, David Lutterkort <lutter at redhat.com> wrote:

> On Wed, 2012-08-01 at 10:54 +0200, Raphaël Pinson wrote:
> > ---
> >  src/augeas.c           |   26 ++++++++++++++++++++++++++
> >  src/augeas.h           |   10 ++++++++++
> >  src/augeas_sym.version |    1 +
> >  src/augrun.c           |   34 +++++++++++++++++++++++++++++++++-
> >  src/augtool.c          |    2 +-
> >  tests/run.tests        |   35 +++++++++++++++++++++++++++++++++++
> >  tests/test-api.c       |   17 +++++++++++++++++
> >  7 files changed, 123 insertions(+), 2 deletions(-)
>
> ACK, with one minor nit: there's no semicolons after functions in C (see
> below)
>
>

Somehow, I think I have seen functions followed by semi-colons in the code,
so I did the same. I'll check again and remove them...



> I also wonder if requiring that SRC matches exactly one node is too
> strict - if somebody wants to 'rename /files/etc/hosts//ipaddr address'
> we should let them, I think.
>
>
That's a good point. Actually, there's another check which might be
interesting: checking that LBL doesn't contain a /. Would that be good?
(though you could want to move the node to a subnode in the same
position...) Is there an internal function I could use to achieve that?


Raphaël



> > diff --git a/src/augrun.c b/src/augrun.c
> > index 7895252..22627ef 100644
> > --- a/src/augrun.c
> > +++ b/src/augrun.c
> > @@ -547,7 +547,7 @@ static void cmd_mv(struct command *cmd) {
> >      if (r < 0)
> >          ERR_REPORT(cmd, AUG_ECMDRUN,
> >                     "Moving %s to %s failed", src, dst);
> > -}
> > +};
>
> No semicolon here
>
> > +static void cmd_rename(struct command *cmd) {
> > +    const char *src = arg_value(cmd, "src");
> > +    const char *lbl = arg_value(cmd, "lbl");
> > +    int r;
> > +
> > +    r = aug_rename(cmd->aug, src, lbl);
> > +    if (r < 0)
> > +        ERR_REPORT(cmd, AUG_ECMDRUN,
> > +                   "Renaming %s to %s failed", src, lbl);
> > +};
>
> or here
>
> David
>
>
> _______________________________________________
> augeas-devel mailing list
> augeas-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/augeas-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20120801/62c19208/attachment.htm>


More information about the augeas-devel mailing list