From c115bd2177e186e7b3c4fa81e84d86f1fb5c5aef Mon Sep 17 00:00:00 2001 From: "Eduardo Lima (Etrunko)" Date: Thu, 26 Sep 2013 12:37:57 -0300 Subject: [PATCH] Fix section/key search We only need to set the id of a section if it is not the toplevel Change-Id: If1bfcc07ca657e859493b1cf98c9e68d11016d13 Signed-off-by: Eduardo Lima (Etrunko) --- src/wkb-ibus-config-eet.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/wkb-ibus-config-eet.c b/src/wkb-ibus-config-eet.c index 55f0f25..780b9ac 100644 --- a/src/wkb-ibus-config-eet.c +++ b/src/wkb-ibus-config-eet.c @@ -85,9 +85,11 @@ _config_section_find(struct _config_section *base, const char *section) if (!section) return NULL; - printf("Requested section '%s'\n", section); - if (!strncasecmp(section, base->id, strlen(base->id))) - return base; + if (base->id && !strncasecmp(section, base->id, strlen(section))) + { + printf("Requested section: '%s' match: '%s' \n", section, base->id); + return base; + } EINA_LIST_FOREACH(base->subsections, node, sub) if ((ret = _config_section_find(sub, section))) @@ -110,12 +112,12 @@ _config_section_find_key(struct _config_section *base, const char *section, cons goto end; } - printf("Requested key '%s'\n", name); - EINA_LIST_FOREACH(base->keys, node, key) + EINA_LIST_FOREACH(sec->keys, node, key) { key_id = wkb_config_key_id(key); - if (!strncasecmp(name, key_id, strlen(key_id))) + if (!strcasecmp(name, key_id)) { + printf("Requested key: '%s' match: '%s'\n", name, key_id); ret = key; break; } @@ -130,13 +132,12 @@ end: _section->set_defaults = _config_ ## _id ## _set_defaults; \ if (parent) \ { \ - _section->id = eina_stringshare_printf("%s/" #_id, parent->id); \ + if (parent->id) \ + _section->id = eina_stringshare_printf("%s/" #_id, parent->id); \ + else \ + _section->id = eina_stringshare_add(#_id); \ parent->subsections = eina_list_append(parent->subsections, _section); \ } \ - else \ - { \ - _section->id = eina_stringshare_add("/" #_id); \ - } \ } while (0) #define _config_section_add_key(_section, _section_id, _key_type, _field) \ -- 2.7.4