* Calculate cell width, rows and cols for a table of equal cells, given * table width and how many spaces between cells. */
| 34 | * table width and how many spaces between cells. |
| 35 | */ |
| 36 | static void layout(struct column_data *data, int *width) |
| 37 | { |
| 38 | int i; |
| 39 | |
| 40 | *width = 0; |
| 41 | for (i = 0; i < data->list->nr; i++) |
| 42 | if (*width < data->len[i]) |
| 43 | *width = data->len[i]; |
| 44 | |
| 45 | *width += data->opts.padding; |
| 46 | |
| 47 | data->cols = (data->opts.width - strlen(data->opts.indent)) / *width; |
| 48 | if (data->cols == 0) |
| 49 | data->cols = 1; |
| 50 | |
| 51 | data->rows = DIV_ROUND_UP(data->list->nr, data->cols); |
| 52 | } |
| 53 | |
| 54 | static void compute_column_width(struct column_data *data) |
| 55 | { |