Change xkbcommon file path to include/ subdirectory
[platform/upstream/libxkbcommon.git] / src / text.c
index 2c58b66..290a5ae 100644 (file)
@@ -24,6 +24,8 @@
  *
  ********************************************************/
 
+#include "config.h"
+
 #include "keymap.h"
 #include "text.h"
 
@@ -204,18 +206,23 @@ const LookupEntry symInterpretMatchMaskNames[] = {
     { "AnyOf", MATCH_ANY },
     { "AllOf", MATCH_ALL },
     { "Exactly", MATCH_EXACTLY },
+    { NULL, 0 },
 };
 
 const char *
-ModIndexText(const struct xkb_keymap *keymap, xkb_mod_index_t ndx)
+ModIndexText(struct xkb_context *ctx, const struct xkb_mod_set *mods,
+             xkb_mod_index_t ndx)
 {
     if (ndx == XKB_MOD_INVALID)
         return "none";
 
-    if (ndx >= darray_size(keymap->mods))
+    if (ndx == XKB_MOD_NONE)
+        return "None";
+
+    if (ndx >= mods->num_mods)
         return NULL;
 
-    return xkb_atom_text(keymap->ctx, darray_item(keymap->mods, ndx).name);
+    return xkb_atom_text(ctx, mods->mods[ndx].name);
 }
 
 const char *
@@ -250,9 +257,10 @@ SIMatchText(enum xkb_match_operation type)
 }
 
 const char *
-ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
+ModMaskText(struct xkb_context *ctx, const struct xkb_mod_set *mods,
+            xkb_mod_mask_t mask)
 {
-    char buf[1024];
+    char buf[1024] = {0};
     size_t pos = 0;
     xkb_mod_index_t i;
     const struct xkb_mod *mod;
@@ -263,7 +271,7 @@ ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
     if (mask == MOD_REAL_MASK_ALL)
         return "all";
 
-    darray_enumerate(i, mod, keymap->mods) {
+    xkb_mods_enumerate(i, mod, mods) {
         int ret;
 
         if (!(mask & (1u << i)))
@@ -271,14 +279,14 @@ ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
 
         ret = snprintf(buf + pos, sizeof(buf) - pos, "%s%s",
                        pos == 0 ? "" : "+",
-                       xkb_atom_text(keymap->ctx, mod->name));
+                       xkb_atom_text(ctx, mod->name));
         if (ret <= 0 || pos + ret >= sizeof(buf))
             break;
         else
             pos += ret;
     }
 
-    return strcpy(xkb_context_get_buffer(keymap->ctx, pos + 1), buf);
+    return strcpy(xkb_context_get_buffer(ctx, pos + 1), buf);
 }
 
 const char *