summaryrefslogtreecommitdiff
path: root/hardinfo
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2019-07-12 11:36:09 -0500
committerLeandro A. F. Pereira <leandro@hardinfo.org>2019-07-29 19:40:43 -0700
commit39e61e06d9535adc7b5ef9d3bab15e640a1637f5 (patch)
tree492651e64934ffaa6098909aa2ae40ad4ff2554d /hardinfo
parentf7ca9fb955bf8e2b12f331754f593b5331617d3b (diff)
struct Info: make info_add_computed_group() use info_unflatten()
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'hardinfo')
-rw-r--r--hardinfo/info.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c
index 514795e5..1d78422a 100644
--- a/hardinfo/info.c
+++ b/hardinfo/info.c
@@ -107,12 +107,27 @@ void info_add_computed_group(struct Info *info, const gchar *name, const gchar *
/* This is a scaffolding method: HardInfo should move away from pre-computing
* the strings in favor of storing InfoGroups instead; while modules are not
* fully converted, use this instead. */
- struct InfoGroup group = {
- .name = name,
- .computed = value,
- };
+ struct Info *tmp_info = NULL;
+ struct InfoGroup donor = {};
+ gchar *tmp_str = NULL;
+
+ if (name)
+ tmp_str = g_strdup_printf("[%s]\n%s", name, value);
+ else
+ tmp_str = g_strdup(value);
+
+ tmp_info = info_unflatten(tmp_str);
+ if (tmp_info->groups->len != 1) {
+ fprintf(stderr,
+ "info_add_computed_group(): expected only one group in value! (actual: %d)\n",
+ tmp_info->groups->len);
+ } else {
+ donor = g_array_index(tmp_info->groups, struct InfoGroup, 0);
+ g_array_append_val(info->groups, donor);
+ }
- g_array_append_val(info->groups, group);
+ g_free(tmp_info); // TODO: doesn't do enough
+ g_free(tmp_str);
}
void info_set_column_title(struct Info *info, const gchar *column, const gchar *title)