1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-08 08:58:27 +03:00

format-table: minor modernization

This commit is contained in:
Mike Yuan 2024-12-10 18:50:30 +01:00
parent 3ca09aa4dd
commit da7cd0f500
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3

View File

@ -170,7 +170,7 @@ Table *table_new_raw(size_t n_columns) {
if (!t)
return NULL;
*t = (struct Table) {
*t = (Table) {
.n_columns = n_columns,
.header = true,
.width = SIZE_MAX,
@ -1348,7 +1348,7 @@ int table_hide_column_from_display_internal(Table *t, ...) {
return r;
}
for (size_t i = 0; i < t->n_display_map; i++) {
FOREACH_ARRAY(i, t->display_map, t->n_display_map) {
bool listed = false;
va_list ap;
@ -1359,7 +1359,7 @@ int table_hide_column_from_display_internal(Table *t, ...) {
column = va_arg(ap, size_t);
if (column == SIZE_MAX)
break;
if (column == t->display_map[i]) {
if (column == *i) {
listed = true;
break;
}
@ -1369,7 +1369,7 @@ int table_hide_column_from_display_internal(Table *t, ...) {
if (listed)
continue;
t->display_map[cur++] = t->display_map[i];
t->display_map[cur++] = *i;
}
t->n_display_map = cur;
@ -2190,7 +2190,7 @@ static char *align_string_mem(const char *str, const char *url, size_t new_lengt
return ret;
}
static bool table_data_isempty(TableData *d) {
static bool table_data_isempty(const TableData *d) {
assert(d);
if (d->type == TABLE_EMPTY)
@ -2204,7 +2204,7 @@ static bool table_data_isempty(TableData *d) {
return false;
}
static const char* table_data_color(TableData *d) {
static const char* table_data_color(const TableData *d) {
assert(d);
if (d->color)
@ -2220,17 +2220,17 @@ static const char* table_data_color(TableData *d) {
return NULL;
}
static const char* table_data_rgap_color(TableData *d) {
static const char* table_data_rgap_color(const TableData *d) {
assert(d);
return d->rgap_color ?: d->rgap_color;
}
static const char* table_data_underline(TableData *d) {
static const char* table_data_underline(const TableData *d) {
assert(d);
if (d->underline)
return /* cescape( */ansi_add_underline_grey()/* ) */;
return ansi_add_underline_grey();
if (d->type == TABLE_HEADER)
return ansi_add_underline();
@ -2238,7 +2238,7 @@ static const char* table_data_underline(TableData *d) {
return NULL;
}
static const char* table_data_rgap_underline(TableData *d) {
static const char* table_data_rgap_underline(const TableData *d) {
assert(d);
if (d->rgap_underline)