diff options
author | Burt P <pburt0@gmail.com> | 2019-07-21 12:45:56 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-08-10 16:46:31 -0700 |
commit | 9c478d2a23fac7a2b0d7aa41981571d27631134e (patch) | |
tree | bb69cf49e9d6bfebe180f0b2f1798c764a266fa1 /hardinfo/info.c | |
parent | ff8078c66110e8ea36240c47bc1f069b44d3ab99 (diff) |
shell/info: allow newlines in values
Also fixed a FIXME: use g_key_file_get_string_list().
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'hardinfo/info.c')
-rw-r--r-- | hardinfo/info.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c index bfc11fc2..ac18e0d9 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -18,6 +18,12 @@ #include "hardinfo.h" +/* Using a slightly modified gg_key_file_parse_string_as_value() + * from GLib in flatten(), to escape characters and the separator. + * The function is not public in GLib and we don't have a GKeyFile + * to pass it anyway. */ +#include "gg_key_file_parse_string_as_value.c" + static const gchar *info_column_titles[] = { "TextValue", "Value", "Progress", "Extra1", "Extra2" }; @@ -267,7 +273,9 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint tp); } - g_string_append_printf(output, "%s=%s\n", field->name, field->value); + gchar *escaped_value = gg_key_file_parse_string_as_value(field->value, '|'); + g_string_append_printf(output, "%s=%s\n", field->name, escaped_value); + g_free(escaped_value); } } else if (group->computed) { g_string_append_printf(output, "%s\n", group->computed); |