]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/table-test-align.c
tableprinter: code cleanup, update of formats of double
[libucw.git] / ucw / table-test-align.c
index f0ddfaf0199b99349b397f5254def3db1e77f76c..eb22f2e24b511919ef908ce732c75ea7d729298b 100644 (file)
@@ -14,20 +14,19 @@ enum test_table_cols {
   test_col0_str, test_col1_int, test_col2_uint, test_col3_bool, test_col4_double
 };
 
-static struct table test_tbl = {
+static struct table_template test_tbl = {
   TBL_COLUMNS {
     [test_col0_str] = TBL_COL_STR("col0_str", 30 | CELL_ALIGN_LEFT),
     [test_col1_int] = TBL_COL_INT("col1_int", 8),
     [test_col2_uint] = TBL_COL_UINT("col2_uint", 9),
     [test_col3_bool] = TBL_COL_BOOL("col3_bool", 9 | CELL_ALIGN_LEFT),
-    [test_col4_double] = TBL_COL_DOUBLE("col4_double", 11 | CELL_ALIGN_LEFT, 5),
+    [test_col4_double] = TBL_COL_DOUBLE_FMT("col4_double", 11 | CELL_ALIGN_LEFT, XTYPE_FMT_DEFAULT),
     TBL_COL_END
   },
   TBL_OUTPUT_HUMAN_READABLE,
   TBL_COL_DELIMITER("\t"),
 };
 
-static int test_to_perform = -1;
 static char **cli_table_opts;
 
 static struct opt_section table_printer_opts = {
@@ -99,11 +98,11 @@ int main(int argc UNUSED, char **argv)
   struct fastbuf *out;
   out = bfdopen_shared(1, 4096);
 
-  table_init(&test_tbl);
-  process_command_line_opts(argv, &test_tbl);
+  struct table *tbl = table_init(&test_tbl);
+  process_command_line_opts(argv, tbl);
 
-  print_table(&test_tbl, out);
-  table_cleanup(&test_tbl);
+  print_table(tbl, out);
+  table_cleanup(tbl);
   bclose(out);
 
   return 0;