fix uci rename for anonymous sections
[project/uci.git] / list.c
diff --git a/list.c b/list.c
index 0ddf409..cd6d305 100644 (file)
--- a/list.c
+++ b/list.c
@@ -322,7 +322,7 @@ uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr)
 
        if (!*name)
                name = NULL;
-       else if (!uci_validate_str(name, false))
+       else if (!uci_validate_type(name))
                goto error;
 
        /* if the given index is negative, it specifies the section number from 
@@ -467,7 +467,7 @@ expand_ptr(struct uci_context *ctx, struct uci_ptr *ptr, bool complete)
        UCI_ASSERT(ctx, ptr != NULL);
 
        if (!(ptr->flags & UCI_LOOKUP_DONE))
-               uci_lookup_ptr(ctx, ptr, NULL, 1);
+               UCI_INTERNAL(uci_lookup_ptr, ctx, ptr, NULL, 1);
        if (complete && !(ptr->flags & UCI_LOOKUP_COMPLETE))
                UCI_THROW(ctx, UCI_ERR_NOTFOUND);
        UCI_ASSERT(ctx, ptr->p != NULL);
@@ -527,6 +527,9 @@ int uci_rename(struct uci_context *ctx, struct uci_ptr *ptr)
                free(e->name);
        e->name = n;
 
+       if (e->type == UCI_TYPE_SECTION)
+               uci_to_section(e)->anonymous = false;
+
        return 0;
 }
 
@@ -618,7 +621,7 @@ int uci_set(struct uci_context *ctx, struct uci_ptr *ptr)
        UCI_ASSERT(ctx, ptr->value);
        UCI_ASSERT(ctx, ptr->s || (!ptr->option && ptr->section));
        if (!ptr->option) {
-               UCI_ASSERT(ctx, uci_validate_str(ptr->value, false));
+               UCI_ASSERT(ctx, uci_validate_type(ptr->value));
        }
 
        if (!ptr->o && ptr->s && ptr->option) {