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

Function print_horizontal

src/ls.c:5120–5156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5118}
5119
5120static void
5121print_horizontal (void)
5122{
5123 size_t pos = 0;
5124 idx_t cols = calculate_columns (false);
5125 struct column_info const *line_fmt = &column_info[cols - 1];
5126 struct fileinfo const *f = sorted_file[0];
5127 size_t name_length = length_of_file_name_and_frills (f);
5128 size_t max_name_length = line_fmt->col_arr[0];
5129
5130 /* Print first entry. */
5131 print_file_name_and_frills (f, 0);
5132
5133 /* Now the rest. */
5134 for (idx_t filesno = 1; filesno < cwd_n_used; filesno++)
5135 {
5136 idx_t col = filesno % cols;
5137
5138 if (col == 0)
5139 {
5140 putchar (eolbyte);
5141 pos = 0;
5142 }
5143 else
5144 {
5145 indent (pos + name_length, pos + max_name_length);
5146 pos += max_name_length;
5147 }
5148
5149 f = sorted_file[filesno];
5150 print_file_name_and_frills (f, pos);
5151
5152 name_length = length_of_file_name_and_frills (f);
5153 max_name_length = line_fmt->col_arr[col];
5154 }
5155 putchar (eolbyte);
5156}
5157
5158/* Output name + SEP + ' '. */
5159

Callers 1

print_current_filesFunction · 0.85

Calls 4

calculate_columnsFunction · 0.85
indentFunction · 0.85

Tested by

no test coverage detected