summaryrefslogtreecommitdiffstats
path: root/libsmartcols
diff options
context:
space:
mode:
Diffstat (limited to 'libsmartcols')
-rw-r--r--libsmartcols/src/table_print.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/libsmartcols/src/table_print.c b/libsmartcols/src/table_print.c
index 5606d23de..67e51076e 100644
--- a/libsmartcols/src/table_print.c
+++ b/libsmartcols/src/table_print.c
@@ -387,6 +387,8 @@ static int print_pending_data(
if (!cl->pending_data)
return 0;
+ if (!width)
+ return -EINVAL;
DBG(COL, ul_debugobj(cl, "printing pending data"));
@@ -405,7 +407,8 @@ static int print_pending_data(
if (bytes == (size_t) -1)
goto err;
- step_pending_data(cl, bytes);
+ if (bytes)
+ step_pending_data(cl, bytes);
if (color)
fputs(color, tb->out);
@@ -1065,6 +1068,8 @@ static int count_column_width(struct libscols_table *tb,
size_t len = mbs_safe_width(scols_cell_get_data(&cl->header));
cl->width_min = max(cl->width_min, len);
}
+ if (!cl->width_min)
+ cl->width_min = 1;
}
scols_reset_iter(&itr, SCOLS_ITER_FORWARD);
@@ -1341,6 +1346,10 @@ static int recount_widths(struct libscols_table *tb, struct libscols_buffer *buf
width--;
break;
}
+
+ /* hide zero width columns */
+ if (cl->width == 0)
+ cl->flags |= SCOLS_FL_HIDDEN;
}
/* the current stage is without effect, go to the next */