Display COL_COLUMN or COL_ROW */
| 145 | |
| 146 | /* Display COL_COLUMN or COL_ROW */ |
| 147 | static void display_table(const struct string_list *list, |
| 148 | unsigned int colopts, |
| 149 | const struct column_options *opts) |
| 150 | { |
| 151 | struct column_data data; |
| 152 | int x, y, i, initial_width; |
| 153 | char *empty_cell; |
| 154 | |
| 155 | memset(&data, 0, sizeof(data)); |
| 156 | data.list = list; |
| 157 | data.colopts = colopts; |
| 158 | data.opts = *opts; |
| 159 | |
| 160 | ALLOC_ARRAY(data.len, list->nr); |
| 161 | for (i = 0; i < list->nr; i++) |
| 162 | data.len[i] = item_length(list->items[i].string); |
| 163 | |
| 164 | layout(&data, &initial_width); |
| 165 | |
| 166 | if (colopts & COL_DENSE) |
| 167 | shrink_columns(&data); |
| 168 | |
| 169 | empty_cell = xmallocz(initial_width); |
| 170 | memset(empty_cell, ' ', initial_width); |
| 171 | for (y = 0; y < data.rows; y++) { |
| 172 | for (x = 0; x < data.cols; x++) |
| 173 | if (display_cell(&data, initial_width, empty_cell, x, y)) |
| 174 | break; |
| 175 | } |
| 176 | |
| 177 | free(data.len); |
| 178 | free(data.width); |
| 179 | free(empty_cell); |
| 180 | } |
| 181 | |
| 182 | void print_columns(const struct string_list *list, unsigned int colopts, |
| 183 | const struct column_options *opts) |
no test coverage detected