From b03c05f0888a27c8b7bbb0d98b8df70a3f8c5788 Mon Sep 17 00:00:00 2001 From: Robert Kessl Date: Mon, 28 Jul 2014 14:10:56 +0200 Subject: [PATCH] tableprinter: TBL_COL_ITER_START(END) moved to table.c --- ucw/table.c | 19 +++++++++++++++++++ ucw/table.h | 16 ---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ucw/table.c b/ucw/table.c index e2e61696..eefb4785 100644 --- a/ucw/table.c +++ b/ucw/table.c @@ -296,6 +296,22 @@ const char * table_set_col_order_by_name(struct table *tbl, const char *col_orde /*** Table cells ***/ +/** + * The TBL_COL_ITER_START macro are used for iterating over all instances of a particular column in + * table _tbl. _colidx is the column index in _tbl, _instptr is the pointer to the column instance + * (struct table_col_instance *), _idxval is the index of current column index. The variables are + * enclosed in a block, so they do not introduce variable name collisions. + * + * The TBL_COL_ITER_END macro must close the block started with TBL_COL_ITER_START. + * + * These macros are usually used to hide the implementation details of the column instances linked + * list. This is usefull for definition of new types. + **/ +#define TBL_COL_ITER_START(_tbl, _colidx, _instptr, _idxval) { struct table_col_instance *_instptr = NULL; int _idxval = _tbl->ll_headers[_colidx]; \ + for(_idxval = _tbl->ll_headers[_colidx], _instptr = _tbl->column_order + _idxval; _idxval != -1; _idxval = _tbl->column_order[_idxval].next_column, _instptr = _tbl->column_order + _idxval) + +#define TBL_COL_ITER_END } + static void table_col_raw(struct table *tbl, int col_templ, const char *col_content) { TBL_COL_ITER_START(tbl, col_templ, curr_col_ptr, curr_col) { @@ -314,6 +330,9 @@ void table_col_generic_format(struct table *tbl, int col, void *value, const str } TBL_COL_ITER_END } +#undef TBL_COL_ITER_START +#undef TBL_COL_ITER_END + void table_col_printf(struct table *tbl, int col, const char *fmt, ...) { ASSERT_MSG(col < tbl->column_count && col >= 0, "Table column %d does not exist.", col); diff --git a/ucw/table.h b/ucw/table.h index c1bf73e3..04abd1f3 100644 --- a/ucw/table.h +++ b/ucw/table.h @@ -199,22 +199,6 @@ struct table { #define TBL_FMT_MACHINE_READABLE .formatter = &table_fmt_machine_readable #define TBL_FMT(_fmt) .formatter = _fmt -/** - * The TBL_COL_ITER_START macro are used for iterating over all instances of a particular column in - * table _tbl. _colidx is the column index in _tbl, _instptr is the pointer to the column instance - * (struct table_col_instance *), _idxval is the index of current column index. The variables are - * enclosed in a block, so they do not introduce variable name collisions. - * - * The TBL_COL_ITER_END macro must close the block started with TBL_COL_ITER_START. - * - * These macros are usually used to hide the implementation details of the column instances linked - * list. This is usefull for definition of new types. - **/ -#define TBL_COL_ITER_START(_tbl, _colidx, _instptr, _idxval) { struct table_col_instance *_instptr = NULL; int _idxval = _tbl->ll_headers[_colidx]; \ - for(_idxval = _tbl->ll_headers[_colidx], _instptr = _tbl->column_order + _idxval; _idxval != -1; _idxval = _tbl->column_order[_idxval].next_column, _instptr = _tbl->column_order + _idxval) - -#define TBL_COL_ITER_END } - /** * Creates a new table from a table template. The template should already contain * the definitions of columns. -- 2.39.2