From b091025ac8bb10c37ae25821774747c99444ffba Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 19 Feb 2009 16:51:57 +0100 Subject: [PATCH] Config parser: Let `:append' and `:prepend' on bitmaps be equivalent to `:set'. --- ucw/conf-intr.c | 21 +++++++++++++++------ ucw/doc/config.txt | 3 ++- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ucw/conf-intr.c b/ucw/conf-intr.c index 914c727d..dcde639a 100644 --- a/ucw/conf-intr.c +++ b/ucw/conf-intr.c @@ -228,6 +228,8 @@ interpret_add_list(struct cf_item *item, int number, char **pars, int *processed static char * interpret_add_bitmap(struct cf_item *item, int number, char **pars, int *processed, u32 *ptr, enum cf_operation op) { + if (op == OP_PREPEND || op == OP_APPEND) + op = OP_SET; if (op != OP_SET && op != OP_REMOVE) return cf_printf("Cannot apply operation %s on a bitmap", cf_op_names[op]); else if (item->type != CT_INT && item->type != CT_LOOKUP) @@ -590,12 +592,19 @@ cf_modify_item(struct cf_item *item, enum cf_operation op, int number, char **pa break; case OP_APPEND: case OP_PREPEND: - if (item->cls == CC_DYNAMIC) - msg = interpret_add_dynamic(item, number, pars, &taken, item->ptr, op); - else if (item->cls == CC_LIST) - msg = interpret_add_list(item, number, pars, &taken, item->ptr, op); - else - return "The attribute does not support append/prepend"; + switch (item->cls) { + case CC_DYNAMIC: + msg = interpret_add_dynamic(item, number, pars, &taken, item->ptr, op); + break; + case CC_LIST: + msg = interpret_add_list(item, number, pars, &taken, item->ptr, op); + break; + case CC_BITMAP: + msg = interpret_add_bitmap(item, number, pars, &taken, item->ptr, op); + break; + default: + return "The attribute does not support append/prepend"; + } break; case OP_REMOVE: if (item->cls == CC_BITMAP) diff --git a/ucw/doc/config.txt b/ucw/doc/config.txt index 4e036cad..f912befd 100644 --- a/ucw/doc/config.txt +++ b/ucw/doc/config.txt @@ -129,7 +129,8 @@ or specify the new values using the shorter one-line syntax. The commands :clear, :append, and :prepend are also supported by var-length arrays. The command :clear can also be used on string values. The following -operations can be used on bitmaps: :set, :remove, :clear, and :all. +operations can be used on bitmaps: :set (which is equal to :append and :prepend), +:remove, :clear, and :all (set all bits). [[include]] Including other files -- 2.39.2