代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 2fb7d36caf560e4ce57265673da7a518d7a5348f Mon Sep 17 00:00:00 2001
From: Yu Watanabe <[email protected]>
Date: Tue, 16 Jul 2019 00:44:14 +0900
Subject: [PATCH] format-table: add TABLE_TIMESTAMP_UTC and _RELATIVE
(cherry picked from commit c5bbb2b5be079852d92d16ebc0d0840929ed82e1)
Related: #2156786
---
src/basic/format-table.c | 25 ++++++++++++++++++-------
src/basic/format-table.h | 2 ++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/basic/format-table.c b/src/basic/format-table.c
index c541e92b3c..5f2e5e3d73 100644
--- a/src/basic/format-table.c
+++ b/src/basic/format-table.c
@@ -236,6 +236,8 @@ static size_t table_data_size(TableDataType type, const void *data) {
return sizeof(bool);
case TABLE_TIMESTAMP:
+ case TABLE_TIMESTAMP_UTC:
+ case TABLE_TIMESTAMP_RELATIVE:
case TABLE_TIMESPAN:
return sizeof(usec_t);
@@ -700,6 +702,8 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
break;
case TABLE_TIMESTAMP:
+ case TABLE_TIMESTAMP_UTC:
+ case TABLE_TIMESTAMP_RELATIVE:
case TABLE_TIMESPAN:
buffer.usec = va_arg(ap, usec_t);
data = &buffer.usec;
@@ -837,11 +841,9 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
return 0;
case TABLE_TIMESTAMP:
- if (a->timestamp < b->timestamp)
- return -1;
- if (a->timestamp > b->timestamp)
- return 1;
- return 0;
+ case TABLE_TIMESTAMP_UTC:
+ case TABLE_TIMESTAMP_RELATIVE:
+ return CMP(a->timestamp, b->timestamp);
case TABLE_TIMESPAN:
if (a->timespan < b->timespan)
@@ -952,14 +954,23 @@ static const char *table_data_format(TableData *d) {
case TABLE_BOOLEAN:
return yes_no(d->boolean);
- case TABLE_TIMESTAMP: {
+ case TABLE_TIMESTAMP:
+ case TABLE_TIMESTAMP_UTC:
+ case TABLE_TIMESTAMP_RELATIVE: {
_cleanup_free_ char *p;
+ char *ret;
p = new(char, FORMAT_TIMESTAMP_MAX);
if (!p)
return NULL;
- if (!format_timestamp(p, FORMAT_TIMESTAMP_MAX, d->timestamp))
+ if (d->type == TABLE_TIMESTAMP)
+ ret = format_timestamp(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
+ else if (d->type == TABLE_TIMESTAMP_UTC)
+ ret = format_timestamp_utc(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
+ else
+ ret = format_timestamp_relative(p, FORMAT_TIMESTAMP_MAX, d->timestamp);
+ if (!ret)
return "n/a";
d->formatted = TAKE_PTR(p);
diff --git a/src/basic/format-table.h b/src/basic/format-table.h
index 5a076b5383..1c8ab5436d 100644
--- a/src/basic/format-table.h
+++ b/src/basic/format-table.h
@@ -12,6 +12,8 @@ typedef enum TableDataType {
TABLE_STRING,
TABLE_BOOLEAN,
TABLE_TIMESTAMP,
+ TABLE_TIMESTAMP_UTC,
+ TABLE_TIMESTAMP_RELATIVE,
TABLE_TIMESPAN,
TABLE_SIZE,
TABLE_UINT32,
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。