]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: reset cell wrapping if all done
authorKarel Zak <kzak@redhat.com>
Thu, 19 Oct 2023 08:48:59 +0000 (10:48 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Oct 2023 19:54:00 +0000 (21:54 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/column.c
libsmartcols/src/print.c
libsmartcols/src/smartcolsP.h

index 3fce60035ed0ea86598185e92b5dde883bb9cf12..cff7d14e742c62ff54b0965912dd5098b3eaeb53 100644 (file)
@@ -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;
index 20f86f44e957c16a1e5a59ec52ab3c32a171af40..d6a2753dbb5addd1f3f4ccc87873f8e06a720a55 100644 (file)
@@ -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);
index 1ffdf23f60c2c8683082c1b09bab39ef8fa06753..afb0c4b77dda57410d156cb51680f90cf7709f0a 100644 (file)
@@ -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);