diff options
author | Burt P <pburt0@gmail.com> | 2020-01-06 00:53:51 -0600 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2020-01-17 16:15:54 -0800 |
commit | 73142b793562158babf717422262bd1011ef17e4 (patch) | |
tree | f391c896e77dd23d59d4390387befddaedd2b393 /shell | |
parent | c6f9dfec60f4bb5039e0dbb758313af58725242c (diff) |
shell: new flag/funcs for escaping label part in keys
Will allow formerly forbidden characters in a label, "#$="
See:
https://github.com/lpereira/hardinfo/issues/509
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'shell')
-rw-r--r-- | shell/shell.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/shell/shell.c b/shell/shell.c index 09a86dae..c0fc011e 100644 --- a/shell/shell.c +++ b/shell/shell.c @@ -1319,14 +1319,16 @@ static void group_handle_normal(GKeyFile *key_file, struct UpdateTableItem *item = g_new0(struct UpdateTableItem, 1); item->is_iter = TRUE; item->iter = gtk_tree_iter_copy(&child); - gchar *flags, *tag, *name; - key_get_components(key, &flags, &tag, &name, NULL, NULL, TRUE); + gchar *flags, *tag, *name, *label; + key_get_components(key, &flags, &tag, &name, &label, NULL, TRUE); if (flags) { - gtk_tree_store_set(store, &child, INFO_TREE_COL_NAME, name, + //TODO: name was formerly used where label is here. Check all uses + //for problems. + gtk_tree_store_set(store, &child, INFO_TREE_COL_NAME, label, INFO_TREE_COL_DATA, flags, -1); g_hash_table_insert(update_tbl, tag, item); - g_free(name); + g_free(label); } else { gtk_tree_store_set(store, &child, INFO_TREE_COL_NAME, key, INFO_TREE_COL_DATA, NULL, -1); @@ -2255,8 +2257,18 @@ gboolean key_value_has_vendor_string(const gchar *key) { return FALSE; } +gboolean key_label_is_escaped(const gchar *key) { + gchar *flags; + key_get_components(key, &flags, NULL, NULL, NULL, NULL, TRUE); + if (flags && strchr(flags, '@')) { + g_free(flags); + return TRUE; + } + return FALSE; +} + gchar *key_mi_tag(const gchar *key) { - static char flag_list[] = "*!^"; + static char flag_list[] = "*!^@"; gchar *p = (gchar*)key, *l, *t; if (key_is_flagged(key)) { @@ -2328,5 +2340,13 @@ void key_get_components(const gchar *key, *lbp = 0; if (lbp && dis) *dis = g_strdup(lbp + 1); + + if (flags && *flags && strchr(*flags, '@')) { + printf("flag@: %s\n", *label); + gchar *ol = *label; + *label = g_strcompress(ol); + g_free(ol); + printf("..... %s\n", *label); + } } } |