From: Karel Zak Date: Thu, 19 Oct 2023 08:48:59 +0000 (+0200) Subject: libsmartcols: reset cell wrapping if all done X-Git-Tag: v2.40-rc1~188 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c5310d4a3121dbcb2e137a0a2db20bca3c3e4ad5;p=thirdparty%2Futil-linux.git libsmartcols: reset cell wrapping if all done Signed-off-by: Karel Zak --- diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c index 3fce60035e..cff7d14e74 100644 --- a/libsmartcols/src/column.c +++ b/libsmartcols/src/column.c @@ -802,7 +802,7 @@ int scols_column_set_properties(struct libscols_column *cl, const char *opts) return rc; } -static void scols_column_reset_wrap(struct libscols_column *cl) +void scols_column_reset_wrap(struct libscols_column *cl) { if (!cl) return; diff --git a/libsmartcols/src/print.c b/libsmartcols/src/print.c index 20f86f44e9..d6a2753dbb 100644 --- a/libsmartcols/src/print.c +++ b/libsmartcols/src/print.c @@ -649,7 +649,7 @@ static int print_data(struct libscols_table *tb, struct ul_buffer *buf) } /* - * Copy curret cell data to buffer. The @cal means "calculation" phase. + * Copy current cell data to buffer. The @cal means "calculation" phase. */ int __cursor_to_buffer(struct libscols_table *tb, struct ul_buffer *buf, @@ -689,6 +689,7 @@ int __cursor_to_buffer(struct libscols_table *tb, data = scols_cell_get_data(ce); datasiz = scols_cell_get_datasiz(ce); } + DBG(CELL, ul_debugobj(cl, "cursor data: '%s' [%zu]", data, datasiz)); } if (!scols_column_is_tree(cl)) @@ -718,6 +719,9 @@ notree: if (!rc && data && datasiz) rc = ul_buffer_append_data(buf, data, datasiz); + /* reset wrapping after greatest chunk calculation */ + if (cal && scols_column_is_wrap(cl)) + scols_column_reset_wrap(cl); return rc; } @@ -777,6 +781,8 @@ static int print_line(struct libscols_table *tb, rc = print_pending_data(tb, buf); if (!rc && scols_column_has_pending_wrap(cl)) pending = 1; + if (!rc && !pending) + scols_column_reset_wrap(cl); } else print_empty_cell(tb, cl, ln, NULL, ul_buffer_get_bufsiz(buf)); scols_table_reset_cursor(tb); diff --git a/libsmartcols/src/smartcolsP.h b/libsmartcols/src/smartcolsP.h index 1ffdf23f60..afb0c4b77d 100644 --- a/libsmartcols/src/smartcolsP.h +++ b/libsmartcols/src/smartcolsP.h @@ -307,6 +307,7 @@ int scols_line_next_group_child(struct libscols_line *ln, /* * column.c */ +void scols_column_reset_wrap(struct libscols_column *cl); int scols_column_next_wrap( struct libscols_column *cl, struct libscols_cell *ce, char **data);