From a4d01b4889c565e9ef0f47d2108f49ca14097027 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Wed, 9 Jul 2014 12:45:43 +0200 Subject: [PATCH] tableprinter: update of linked list --- ucw/table.c | 14 ++++++-------- ucw/table.h | 5 +++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ucw/table.c b/ucw/table.c index 0dd108c9..d6850352 100644 --- a/ucw/table.c +++ b/ucw/table.c @@ -161,7 +161,6 @@ static void table_update_ll(struct table *tbl) for(int i = 0; i < tbl->column_count; i++) { tbl->columns[i].first_column = -1; - tbl->columns[i].last_column = -1; } for(int i = 0; i < cols_to_output; i++) { @@ -170,15 +169,14 @@ static void table_update_ll(struct table *tbl) } for(int i = 0; i < cols_to_output; i++) { - int last = tbl->column_order[i].col_def->last_column; - if(last != -1) { - tbl->column_order[i].col_def->last_column = i; - tbl->column_order[last].next_column = i; + int first = tbl->column_order[i].col_def->first_column; + tbl->column_order[i].col_def->first_column = i; + + if(first != -1) { + tbl->column_order[i].next_column = first; } else { - tbl->column_order[i].col_def->last_column = i; - tbl->column_order[i].col_def->first_column = i; + tbl->column_order[i].next_column = -1; } - tbl->column_order[i].next_column = -1; } } diff --git a/ucw/table.h b/ucw/table.h index 5ca60d75..f4163d30 100644 --- a/ucw/table.h +++ b/ucw/table.h @@ -125,11 +125,12 @@ struct table_column { const char *fmt; // [*] Default format of each cell in the column enum column_type type; // [*] Type of the cells in the column int first_column; // head of linked list of columns of this type - int last_column; // tail of linked list of columns of this type + //int last_column; // tail of linked list of columns of this type struct table_user_type *type_def; }; // FIXME: is it correct to have idx and col_def? idx is sufficient and in fact a duplicity of idx +// idx is used only for initialization and col_def is used in other cases struct table_col_info { uint idx; // idx is a pointer to struct table::columns struct table_column *col_def; // this is pointer to the column definition, located in the array struct table::columns @@ -198,7 +199,7 @@ struct table { * ***/ -#define TBL_COL_LIST_INIT .first_column = -1, .last_column = -1 +#define TBL_COL_LIST_INIT .first_column = -1 #define TBL_COL_STR(_name, _width) { .name = _name, .width = _width, .fmt = "%s", .type = COL_TYPE_STR, TBL_COL_LIST_INIT } #define TBL_COL_INT(_name, _width) { .name = _name, .width = _width, .fmt = "%d", .type = COL_TYPE_INT, TBL_COL_LIST_INIT } #define TBL_COL_S64(_name, _width) { .name = _name, .width = _width, .fmt = "%lld", .type = COL_TYPE_S64, TBL_COL_LIST_INIT } -- 2.39.5