MCPcopy Create free account
hub / github.com/coreutils/coreutils / print_many_per_line

Function print_many_per_line

src/ls.c:5085–5118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5083}
5084
5085static void
5086print_many_per_line (void)
5087{
5088 idx_t cols = calculate_columns (true);
5089 struct column_info const *line_fmt = &column_info[cols - 1];
5090
5091 /* Calculate the number of rows that will be in each column except possibly
5092 for a short column on the right. */
5093 idx_t rows = cwd_n_used / cols + (cwd_n_used % cols != 0);
5094
5095 for (idx_t row = 0; row < rows; row++)
5096 {
5097 size_t col = 0;
5098 idx_t filesno = row;
5099 size_t pos = 0;
5100
5101 /* Print the next row. */
5102 while (true)
5103 {
5104 struct fileinfo const *f = sorted_file[filesno];
5105 size_t name_length = length_of_file_name_and_frills (f);
5106 size_t max_name_length = line_fmt->col_arr[col++];
5107 print_file_name_and_frills (f, pos);
5108
5109 if (cwd_n_used - rows <= filesno)
5110 break;
5111 filesno += rows;
5112
5113 indent (pos + name_length, pos + max_name_length);
5114 pos += max_name_length;
5115 }
5116 putchar (eolbyte);
5117 }
5118}
5119
5120static void
5121print_horizontal (void)

Callers 1

print_current_filesFunction · 0.85

Calls 4

calculate_columnsFunction · 0.85
indentFunction · 0.85

Tested by

no test coverage detected