Fix section/key search
authorEduardo Lima (Etrunko) <eduardo.lima@intel.com>
Thu, 26 Sep 2013 15:37:57 +0000 (12:37 -0300)
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>
Thu, 26 Sep 2013 20:33:24 +0000 (17:33 -0300)
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) <eduardo.lima@intel.com>
src/wkb-ibus-config-eet.c

index 55f0f25..780b9ac 100644 (file)
@@ -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) \