]> pilppa.com Git - uci.git/commitdiff
cleanup, fix rename
authorFelix Fietkau <nbd@pi.lan>
Fri, 22 Aug 2008 18:17:09 +0000 (20:17 +0200)
committerFelix Fietkau <nbd@pi.lan>
Fri, 22 Aug 2008 18:17:09 +0000 (20:17 +0200)
cli.c
list.c

diff --git a/cli.c b/cli.c
index 5a260ef44907f87ce412b84ea95d043cdc0a042f..290dcbfddaae976af725cbf5d13530b2593a80aa 100644 (file)
--- a/cli.c
+++ b/cli.c
@@ -187,13 +187,7 @@ static int package_cmd(int cmd, char *tuple)
                return 1;
        }
 
-       if (ptr.o)
-               e = &ptr.o->e;
-       else if (ptr.s)
-               e = &ptr.s->e;
-       else
-               e = &ptr.p->e;
-
+       e = ptr.last;
        switch(cmd) {
        case CMD_CHANGES:
                uci_show_changes(ptr.p);
@@ -341,13 +335,7 @@ static int uci_do_section_cmd(int cmd, int argc, char **argv)
        if (ptr.value && (cmd != CMD_SET) && (cmd != CMD_ADD_LIST) && (cmd != CMD_RENAME))
                return 1;
 
-       if (ptr.o)
-               e = &ptr.o->e;
-       else if (ptr.s)
-               e = &ptr.s->e;
-       else
-               e = &ptr.p->e;
-
+       e = ptr.last;
        switch(cmd) {
        case CMD_GET:
                switch(e->type) {
diff --git a/list.c b/list.c
index e770234424ae92d2b7c109e64f28a847a9ee5ac9..98a6e28a178db5b45e14dc3e62de96f8fa05ee4c 100644 (file)
--- a/list.c
+++ b/list.c
@@ -350,6 +350,7 @@ error:
        UCI_THROW(ctx, UCI_ERR_INVAL);
 done:
        free(section);
+       ptr->section = e->name;
        return e;
 }
 
@@ -371,8 +372,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 +391,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 +400,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: