summaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-03 19:11:57 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-03 19:26:39 +0200
commit134a627130a732f6315d323895365dd59fab95c5 (patch)
tree8c1b128b3f5e1ffe58d5791a68c4b31962d2f49b /degesch.c
parent1e3a27369080c6f189fd0d8d5151f23ec082a61f (diff)
downloadxK-134a627130a732f6315d323895365dd59fab95c5.tar.gz
xK-134a627130a732f6315d323895365dd59fab95c5.tar.xz
xK-134a627130a732f6315d323895365dd59fab95c5.zip
degesch: finish /set
One bug remaining to make it work.
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/degesch.c b/degesch.c
index de40462..a60c4e9 100644
--- a/degesch.c
+++ b/degesch.c
@@ -3835,6 +3835,8 @@ handle_command_set_add
struct str_vector items;
str_vector_init (&items);
split_str (item->value.string.str, ',', &items);
+ if (items.len == 1 && !*items.vector[0])
+ str_vector_reset (&items);
if (str_vector_find (&items, value) != -1)
error_set (e, "already present in the array: %s", value);
@@ -3856,6 +3858,8 @@ handle_command_set_remove
struct str_vector items;
str_vector_init (&items);
split_str (item->value.string.str, ',', &items);
+ if (items.len == 1 && !*items.vector[0])
+ str_vector_reset (&items);
ssize_t i = str_vector_find (&items, value);
if (i == -1)
@@ -3870,14 +3874,6 @@ handle_command_set_remove
return result;
}
-static bool
-handle_command_set_replace (struct app_context *ctx,
- struct config_item_ *item, struct config_item_ *new_, struct error **e)
-{
- // TODO: replace the item (or log error)
- return false;
-}
-
static void
handle_command_set_assign_item (struct app_context *ctx,
char *key, struct config_item_ *new_, bool add, bool remove)
@@ -3895,7 +3891,7 @@ handle_command_set_assign_item (struct app_context *ctx,
else if (remove)
handle_command_set_remove (item, new_->value.string.str, &e);
else
- handle_command_set_replace (ctx, item, new_, &e);
+ config_item_set_from (item, config_item_clone (new_), &e);
if (e)
{