case TABLE_STRV: {
char *p;
+ if (strv_isempty(d->strv))
+ return strempty(t->empty_string);
+
p = strv_join(d->strv, "\n");
if (!p)
return NULL;
return ret;
}
+static bool table_data_isempty(TableData *d) {
+ assert(d);
+
+ if (d->type == TABLE_EMPTY)
+ return true;
+
+ /* Let's also consider an empty strv as truly empty. */
+ if (d->type == TABLE_STRV)
+ return strv_isempty(d->strv);
+
+ /* Note that an empty string we do not consider empty here! */
+ return false;
+}
+
static const char* table_data_color(TableData *d) {
assert(d);
return d->color;
/* Let's implicitly color all "empty" cells in grey, in case an "empty_string" is set that is not empty */
- if (d->type == TABLE_EMPTY)
+ if (table_data_isempty(d))
return ansi_grey();
return NULL;