From 78ad0f615d029e348fb6cc7b214f92b582e7cc03 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 30 May 2014 16:04:06 +0200 Subject: [PATCH] Table: Fixed bugs in header printing configuration Previously, the user-defined setting of table->print_header was overwritten at various locations, making multiple uses of table_start()/table_end() on a single table close to unusable. Now, table->print_header is not modified by the table printer itself, except for table_init(). --- ucw/table.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ucw/table.c b/ucw/table.c index 352cf936..006e44f9 100644 --- a/ucw/table.c +++ b/ucw/table.c @@ -85,7 +85,6 @@ void table_end(struct table *tbl) { tbl->last_printed_col = -1; tbl->row_printing_started = 0; - tbl->print_header = 1; mp_restore(tbl->pool, &tbl->pool_state); @@ -456,7 +455,6 @@ static void table_start_human_readable(struct table *tbl) } if(tbl->print_header != 0) { - tbl->print_header = 0; table_write_header(tbl); } } @@ -492,10 +490,6 @@ static void table_start_machine_readable(struct table *tbl) } if(tbl->print_header != 0) { - // FIXME: This magic is not needed, the value of print_header should be kept - // to the value set during table initialization (e.g., by command-line options) - tbl->print_header = 0; - uint col_idx = tbl->column_order[0]; bputs(tbl->out, tbl->columns[col_idx].name); for(uint i = 1; i < tbl->cols_to_output; i++) { @@ -584,6 +578,7 @@ static void test_simple1(struct fastbuf *out) table_start(&test_tbl); do_print1(&test_tbl); table_end(&test_tbl); + test_tbl.print_header = 1; table_col_order_by_name(&test_tbl, "col3_bool"); table_start(&test_tbl); -- 2.39.2