From: Yu Watanabe Date: Thu, 9 Jan 2020 11:14:30 +0000 (+0900) Subject: format-table: introduce TABLE_PATH X-Git-Tag: v245-rc1~158^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f93d876c80a69563c208852c8a8183ad64a593e7;p=thirdparty%2Fsystemd.git format-table: introduce TABLE_PATH --- diff --git a/src/shared/format-table.c b/src/shared/format-table.c index 4617ae8badc..47d56dd085b 100644 --- a/src/shared/format-table.c +++ b/src/shared/format-table.c @@ -14,6 +14,7 @@ #include "memory-util.h" #include "pager.h" #include "parse-util.h" +#include "path-util.h" #include "pretty-print.h" #include "sort-util.h" #include "string-util.h" @@ -234,6 +235,7 @@ static size_t table_data_size(TableDataType type, const void *data) { return 0; case TABLE_STRING: + case TABLE_PATH: return strlen(data) + 1; case TABLE_BOOLEAN: @@ -768,6 +770,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) { break; case TABLE_STRING: + case TABLE_PATH: data = va_arg(ap, const char *); break; @@ -1038,6 +1041,9 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t case TABLE_STRING: return strcmp(a->string, b->string); + case TABLE_PATH: + return path_compare(a->string, b->string); + case TABLE_BOOLEAN: if (!a->boolean && b->boolean) return -1; @@ -1151,6 +1157,7 @@ static const char *table_data_format(Table *t, TableData *d) { return strempty(t->empty_string); case TABLE_STRING: + case TABLE_PATH: if (d->uppercase) { char *p, *q; @@ -1897,6 +1904,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) { return json_variant_new_null(ret); case TABLE_STRING: + case TABLE_PATH: return json_variant_new_string(ret, d->string); case TABLE_BOOLEAN: diff --git a/src/shared/format-table.h b/src/shared/format-table.h index 80f319d054a..b23e4de99d0 100644 --- a/src/shared/format-table.h +++ b/src/shared/format-table.h @@ -11,6 +11,7 @@ typedef enum TableDataType { TABLE_EMPTY, TABLE_STRING, + TABLE_PATH, TABLE_BOOLEAN, TABLE_TIMESTAMP, TABLE_TIMESTAMP_UTC,