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:
@@ -354,7 +354,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
|
||||
|
||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
|
||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 4), 100);
|
||||
(void) table_set_empty_string(table, "-");
|
||||
table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
|
||||
(void) table_set_sort(table, (size_t) 3, (size_t) 8);
|
||||
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6, (size_t) 7);
|
||||
}
|
||||
@@ -657,7 +657,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
|
||||
return log_oom();
|
||||
|
||||
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
|
||||
(void) table_set_empty_string(table, "-");
|
||||
table_set_ersatz_string(table, TABLE_ERSATZ_DASH);
|
||||
(void) table_set_sort(table, (size_t) 3, (size_t) 5);
|
||||
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user