# HG changeset patch # User jwe # Date 822898197 0 # Node ID ba9c6243020206c98215c3867b7834a3e0a3a87d # Parent 793ce4135de790e64c4814d888b5cdf1b1da0b98 [project @ 1996-01-29 06:49:27 by jwe] diff --git a/src/utils.cc b/src/utils.cc --- a/src/utils.cc +++ b/src/utils.cc @@ -451,73 +451,6 @@ return is_empty; } -// Format a list in neat columns. Mostly stolen from GNU ls. - -ostrstream& -list_in_columns (ostrstream& os, const string_vector& list) -{ - // Compute the maximum name length. - - int max_name_length = 0; - int total_names = list.length (); - - for (int i = 0; i < total_names; i++) - { - int name_length = list[i].length (); - if (name_length > max_name_length) - max_name_length = name_length; - } - - // Allow at least two spaces between names. - - max_name_length += 2; - - // Calculate the maximum number of columns that will fit. - - int line_length = terminal_columns (); - int cols = line_length / max_name_length; - if (cols == 0) - cols = 1; - - // Calculate the number of rows that will be in each column except - // possibly for a short column on the right. - - int rows = total_names / cols + (total_names % cols != 0); - - // Recalculate columns based on rows. - - cols = total_names / rows + (total_names % rows != 0); - - int count; - for (int row = 0; row < rows; row++) - { - count = row; - int pos = 0; - - // Print the next row. - - while (1) - { - string nm = list[count]; - - os << nm; - int name_length = nm.length (); - - count += rows; - if (count >= total_names) - break; - - int spaces_to_pad = max_name_length - name_length; - for (int i = 0; i < spaces_to_pad; i++) - os << " "; - pos += max_name_length; - } - os << "\n"; - } - - return os; -} - // See if the given file is in the path. string diff --git a/src/utils.h b/src/utils.h --- a/src/utils.h +++ b/src/utils.h @@ -70,8 +70,6 @@ extern int empty_arg (const char *name, int nr, int nc); -extern ostrstream& list_in_columns (ostrstream& os, const string_vector& list); - extern string undo_string_escapes (const string& s); extern void oct_putenv (const char *, const char *);