X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fuci.git;a=blobdiff_plain;f=list.c;h=83f016e858b418d48cb550b81faa48e42f95ac5b;hp=e770234424ae92d2b7c109e64f28a847a9ee5ac9;hb=b485972f3a40be1627fb2bdd9904889a155f12e0;hpb=563f8dd6f0eb56780a00f5856bf7fcf40e39d845 diff --git a/list.c b/list.c index e770234..83f016e 100644 --- a/list.c +++ b/list.c @@ -269,7 +269,8 @@ uci_free_any(struct uci_element **e) *e = NULL; } -static struct uci_element *uci_lookup_list(struct uci_list *list, const char *name) +static inline struct uci_element * +uci_lookup_list(struct uci_list *list, const char *name) { struct uci_element *e; @@ -280,7 +281,8 @@ static struct uci_element *uci_lookup_list(struct uci_list *list, const char *na return NULL; } -static struct uci_element *uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr) +static struct uci_element * +uci_lookup_ext_section(struct uci_context *ctx, struct uci_ptr *ptr) { char *idxstr, *t, *section, *name; struct uci_element *e = NULL; @@ -350,10 +352,12 @@ error: UCI_THROW(ctx, UCI_ERR_INVAL); done: free(section); + ptr->section = e->name; return e; } -int uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool extended) +int +uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool extended) { struct uci_element *e; @@ -371,8 +375,10 @@ int uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool UCI_INTERNAL(uci_load, ctx, ptr->package, &ptr->p); if (!ptr->p) goto notfound; + ptr->last = &ptr->p->e; } else { ptr->p = uci_to_package(e); + ptr->last = e; } if (!ptr->section) @@ -388,6 +394,7 @@ int uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool if (!e) goto abort; + ptr->last = e; ptr->s = uci_to_section(e); if (ptr->option) { @@ -396,6 +403,7 @@ int uci_lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, char *str, bool goto abort; ptr->o = uci_to_option(e); + ptr->last = e; } complete: