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
UCI_THROW(ctx, UCI_ERR_INVAL);
done:
free(section);
- ptr->section = e->name;
+ if (e)
+ ptr->section = e->name;
return e;
}
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);
free(e->name);
e->name = n;
+ if (e->type == UCI_TYPE_SECTION)
+ uci_to_section(e)->anonymous = false;
+
return 0;
}
uci_add_history(ctx, &p->history, UCI_CMD_REMOVE, ptr->section, ptr->option, NULL);
uci_free_any(&e);
+
+ if (ptr->option)
+ ptr->o = NULL;
+ else if (ptr->section)
+ ptr->s = NULL;
+
return 0;
}
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) {