]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sys-utils/lscpu: Change object type to SCOLS_JSON_STRING if data == "-"
authorWanBingjiang <614699596@qq.com>
Thu, 27 Feb 2025 07:13:37 +0000 (15:13 +0800)
committerWanBingjiang <614699596@qq.com>
Thu, 27 Feb 2025 07:18:47 +0000 (15:18 +0800)
sys-utils/lscpu.c

index 9dd12a64f99dc5f845cc26134e33f1d05bb4ed62..ffec37206587aff100830b6717a13d82c9ead686 100644 (file)
@@ -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"));
                }