make the value of an option optional (found by lubek)
[project/uci.git] / history.c
index 0526361..202d787 100644 (file)
--- a/history.c
+++ b/history.c
@@ -82,7 +82,7 @@ static void uci_parse_history_line(struct uci_context *ctx, struct uci_package *
                goto error;
        if (option && !uci_validate_name(option))
                goto error;
-       if ((rename || !delete) && !uci_validate_name(value))
+       if ((rename || (!option && !delete)) && !uci_validate_name(value))
                goto error;
 
        if (rename)
@@ -275,13 +275,13 @@ int uci_revert(struct uci_context *ctx, struct uci_package **pkg, char *section,
 
        UCI_INTERNAL(uci_load, ctx, name, &p);
        UCI_TRAP_RESTORE(ctx);
+       ctx->errno = 0;
 
-       goto done;
 error:
        if (name)
                free(name);
-       UCI_THROW(ctx, ctx->errno);
-done:
+       if (ctx->errno)
+               UCI_THROW(ctx, ctx->errno);
        return 0;
 }