1
0
mirror of https://github.com/irssi/irssi.git synced 2024-11-03 04:27:19 -05:00

get_max_column_count() didn't return correct value in save_column_widths

when it returned only one column.


git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1510 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Timo Sirainen 2001-05-21 23:46:48 +00:00 committed by cras
parent 24e88a6772
commit 666f4b2463

View File

@ -628,7 +628,7 @@ int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
GSList *tmp; GSList *tmp;
int **columns, *columns_width, *columns_rows; int **columns, *columns_width, *columns_rows;
int item_pos, items_count; int item_pos, items_count;
int ret, len, n, col; int ret, len, max_len, n, col;
items_count = g_slist_length(items); items_count = g_slist_length(items);
if (items_count == 0) { if (items_count == 0) {
@ -654,9 +654,12 @@ int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
/* for each possible column count, save the column widths and /* for each possible column count, save the column widths and
find the biggest column count that fits to screen. */ find the biggest column count that fits to screen. */
item_pos = 0; item_pos = 0; max_len = 0;
for (tmp = items; tmp != NULL; tmp = tmp->next) { for (tmp = items; tmp != NULL; tmp = tmp->next) {
len = item_extra+len_func(tmp->data); len = item_extra+len_func(tmp->data);
if (max_len < len)
max_len = len;
for (n = 1; n < max_columns; n++) { for (n = 1; n < max_columns; n++) {
if (columns_width[n] > max_width) if (columns_width[n] > max_width)
continue; /* too wide */ continue; /* too wide */
@ -680,7 +683,7 @@ int get_max_column_count(GSList *items, COLUMN_LEN_FUNC len_func,
*save_column_widths = g_new(int, ret); *save_column_widths = g_new(int, ret);
if (ret == 1) { if (ret == 1) {
**save_column_widths = item_extra+len_func(items->data); **save_column_widths = max_len;
*rows = 1; *rows = 1;
} else { } else {
memcpy(*save_column_widths, columns[ret-1], sizeof(int)*ret); memcpy(*save_column_widths, columns[ret-1], sizeof(int)*ret);