MCPcopy Index your code
hub / github.com/git/git / display_table

Function display_table

column.c:147–180  ·  view source on GitHub ↗

Display COL_COLUMN or COL_ROW */

Source from the content-addressed store, hash-verified

145
146/* Display COL_COLUMN or COL_ROW */
147static 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
182void print_columns(const struct string_list *list, unsigned int colopts,
183 const struct column_options *opts)

Callers 1

print_columnsFunction · 0.85

Calls 5

item_lengthFunction · 0.85
layoutFunction · 0.85
shrink_columnsFunction · 0.85
xmalloczFunction · 0.85
display_cellFunction · 0.85

Tested by

no test coverage detected