]> mj.ucw.cz Git - libucw.git/commitdiff
tableprinter: header option now parsed by xtypes
authorRobert Kessl <kesslr@centrum.cz>
Tue, 22 Jul 2014 11:08:18 +0000 (13:08 +0200)
committerRobert Kessl <kesslr@centrum.cz>
Tue, 22 Jul 2014 11:08:18 +0000 (13:08 +0200)
ucw/table.c

index 74ca529692368053accc6f8ab34613ae66e1bffb..0c0294e5e9b92188c94a8cf884863fcd9087c90b 100644 (file)
@@ -387,12 +387,13 @@ const char *table_set_option_value(struct table *tbl, const char *key, const cha
   // Options with a value
   if(value) {
     if(strcmp(key, "header") == 0) {
-      if(value[1] != 0)
-        return mp_printf(tbl->pool, "Invalid header parameter: '%s' has invalid value: '%s'.", key, value);
-      uint tmp = value[0] - '0';
-      if(tmp > 1)
+      bool tmp;
+      const char *err = xt_bool.parse(value, &tmp, tbl->pool);
+      if(err)
         return mp_printf(tbl->pool, "Invalid header parameter: '%s' has invalid value: '%s'.", key, value);
+
       tbl->print_header = tmp;
+
       return NULL;
     } else if(strcmp(key, "cols") == 0) {
       return table_set_col_order_by_name(tbl, value);