From 049901c63ea7ad8a1e0ba4feeaf7360dbf4bdc2f Mon Sep 17 00:00:00 2001 From: WanBingjiang <614699596@qq.com> Date: Thu, 27 Feb 2025 15:13:37 +0800 Subject: [PATCH] sys-utils/lscpu: Change object type to SCOLS_JSON_STRING if data == "-" --- sys-utils/lscpu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c index 9dd12a64f99..ffec3720658 100644 --- a/sys-utils/lscpu.c +++ b/sys-utils/lscpu.c @@ -790,9 +790,13 @@ static void print_cpus_readable(struct lscpu_cxt *cxt, int cols[], size_t ncols) err(EXIT_FAILURE, _("failed to allocate output line")); for (c = 0; c < ncols; c++) { + struct libscols_column *cl; data = get_cell_data(cxt, cpu, cols[c], buf, sizeof(buf)); - if (!data || !*data) + if (!data || !*data) { data = "-"; + cl = scols_table_get_column(tb, c); + scols_column_set_json_type(cl, SCOLS_JSON_STRING); + } if (scols_line_set_data(ln, c, data)) err(EXIT_FAILURE, _("failed to add output data")); }