format-table: introduce TABLE_PATH

This commit is contained in:
Yu Watanabe 2020-01-09 20:14:30 +09:00
parent 125c7814fa
commit f93d876c80
2 changed files with 9 additions and 0 deletions

View file

@ -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:

View file

@ -11,6 +11,7 @@
typedef enum TableDataType {
TABLE_EMPTY,
TABLE_STRING,
TABLE_PATH,
TABLE_BOOLEAN,
TABLE_TIMESTAMP,
TABLE_TIMESTAMP_UTC,