[augeas-devel] [PATCH 2/4] aug_mv: report EMVDESC if move would move a node into its descendant
lutter at redhat.com
lutter at redhat.com
Fri Jul 22 22:37:41 UTC 2011
From: David Lutterkort <lutter at redhat.com>
---
src/augeas.c | 9 +++++----
src/augeas.h | 3 ++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/augeas.c b/src/augeas.c
index 896f570..6e323ac 100644
--- a/src/augeas.c
+++ b/src/augeas.c
@@ -72,7 +72,8 @@ static const char *const errcodes[] = {
"Syntax error in lens definition", /* AUG_ESYNTAX */
"Lens not found", /* AUG_ENOLENS */
"Multiple transforms", /* AUG_EMXFM */
- "Node has no span info" /* AUG_ENOSPAN */
+ "Node has no span info", /* AUG_ENOSPAN */
+ "Cannot move node into its descendant" /* AUG_EMVDESC */
};
static void tree_mark_dirty(struct tree *tree) {
@@ -1097,10 +1098,10 @@ int aug_mv(struct augeas *aug, const char *src, const char *dst) {
/* Don't move SRC into its own descendent */
t = td;
do {
- if (t == ts)
- goto error;
+ ERR_THROW(t == ts, aug, AUG_EMVDESC,
+ "destination %s is a descendant of %s", dst, src);
t = t->parent;
- } while (! ROOT_P(t));
+ } while (t != aug->origin);
free_tree(td->children);
diff --git a/src/augeas.h b/src/augeas.h
index 813b7a6..1c23d57 100644
--- a/src/augeas.h
+++ b/src/augeas.h
@@ -320,7 +320,8 @@ typedef enum {
AUG_ESYNTAX, /* Syntax error in lens file */
AUG_ENOLENS, /* Lens lookup failed */
AUG_EMXFM, /* Multiple transforms */
- AUG_ENOSPAN /* No span for this node */
+ AUG_ENOSPAN, /* No span for this node */
+ AUG_EMVDESC /* Cannot move node into its descendant */
} aug_errcode_t;
/* Return the error code from the last API call */
--
1.7.6
More information about the augeas-devel
mailing list