]> mj.ucw.cz Git - libucw.git/commitdiff
Config parser: Let `:append' and `:prepend' on bitmaps be equivalent to `:set'.
authorMartin Mares <mj@ucw.cz>
Thu, 19 Feb 2009 15:51:57 +0000 (16:51 +0100)
committerMartin Mares <mj@ucw.cz>
Thu, 19 Feb 2009 15:51:57 +0000 (16:51 +0100)
ucw/conf-intr.c
ucw/doc/config.txt

index 914c727d8f775601022189d8e6082e5a25339ce5..dcde639a4af7892e6991e7d99134b732d0917851 100644 (file)
@@ -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)
index 4e036cad147a26ce7e755e32ed99602c5f9ab4a3..f912befd7c58d6678a3067672c3b774e5008e1df 100644 (file)
@@ -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