shared/format-table: use enum instead of Table.empty_string

All users were setting this to some static string (usually "-"), so let's
simplify things by not doing strdup, but instead limiting callers to a fixed
set of values. In preparation for the next commit, the function is renamed from
"empty" to "replacement", because it'll be used for more than empty fields. I
didn't do the whole string-table setup, because it's all used internally in one
file and this way we can immediately assert if an invalid value is passed in.

Some callers were (void)ing the error, others were ignoring it, and others
propagating. It's nicer to remove the boilerplate.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2022-09-22 10:16:05 +02:00
parent 5515f2169c
commit c8b62cf600
16 changed files with 51 additions and 34 deletions
+1 -1
View File
@@ -510,7 +510,7 @@ static int context_show_version(Context *c, const char *version) {
(void) table_set_align_percent(t, table_get_cell(t, 0, 6), 100);
(void) table_set_align_percent(t, table_get_cell(t, 0, 7), 100);
(void) table_set_align_percent(t, table_get_cell(t, 0, 8), 100);
(void) table_set_empty_string(t, "-");
table_set_ersatz_string(t, TABLE_ERSATZ_DASH);
/* Determine if the target will make use of partition/fs attributes for any of the transfers */
for (size_t n = 0; n < c->n_transfers; n++) {