unsigned file_id;
struct atom_table *atom_table;
+
+ /* Buffer for the *Text() functions. */
+ char text_buffer[1024];
+ size_t text_next;
};
/**
{
ctx->user_data = user_data;
}
+
+char *
+xkb_context_get_buffer(struct xkb_context *ctx, size_t size)
+{
+ char *rtrn;
+
+ if (size >= sizeof(ctx->text_buffer))
+ return NULL;
+
+ if (sizeof(ctx->text_buffer) - ctx->text_next <= size)
+ ctx->text_next = 0;
+
+ rtrn = &ctx->text_buffer[ctx->text_next];
+ ctx->text_next += size;
+
+ return rtrn;
+}
const char *
xkb_atom_text(struct xkb_context *ctx, xkb_atom_t atom);
+char *
+xkb_context_get_buffer(struct xkb_context *ctx, size_t size);
+
ATTR_PRINTF(3, 4) void
xkb_log(struct xkb_context *ctx, enum xkb_log_level level,
const char *fmt, ...);
{ "Exactly", MATCH_EXACTLY },
};
-#define BUFFER_SIZE 1024
-
-static char *
-GetBuffer(size_t size)
-{
- static char buffer[BUFFER_SIZE];
- static size_t next;
- char *rtrn;
-
- if (size >= BUFFER_SIZE)
- return NULL;
-
- if (BUFFER_SIZE - next <= size)
- next = 0;
-
- rtrn = &buffer[next];
- next += size;
-
- return rtrn;
-}
-
const char *
ModMaskText(const struct xkb_keymap *keymap, xkb_mod_mask_t mask)
{
size_t len;
ssize_t rem;
char *str;
- char buf[BUFFER_SIZE];
+ char buf[1024];
const struct xkb_mod *mod;
if (mask == 0)
str = buf;
buf[0] = '\0';
- rem = BUFFER_SIZE;
+ rem = sizeof(buf);
darray_enumerate(i, mod, keymap->mods) {
if (!(mask & (1 << i)))
continue;
str = buf;
len = strlen(str);
- if (len >= BUFFER_SIZE)
- len = BUFFER_SIZE - 1;
+ if (len >= sizeof(buf))
+ len = sizeof(buf) - 1;
- return strcpy(GetBuffer(len + 1), str);
+ return strcpy(xkb_context_get_buffer(keymap->ctx, len + 1), str);
}
}
const char *
-KeysymText(xkb_keysym_t sym)
+KeysymText(struct xkb_context *ctx, xkb_keysym_t sym)
{
static char buffer[64];
{
const char *sname = xkb_atom_text(ctx, name);
size_t len = strlen(sname) + 3;
- char *buf = GetBuffer(len);
+ char *buf = xkb_context_get_buffer(ctx, len);
snprintf(buf, len, "<%s>", sname);
return buf;
}
ActionTypeText(enum xkb_action_type type);
const char *
-KeysymText(xkb_keysym_t sym);
+KeysymText(struct xkb_context *ctx, xkb_keysym_t sym);
const char *
KeyNameText(struct xkb_context *ctx, xkb_atom_t name);
return "default";
snprintf(buf, sizeof(buf), "%s+%s(%s)",
- KeysymText(si->interp.sym),
+ KeysymText(info->keymap->ctx, si->interp.sym),
SIMatchText(si->interp.match),
ModMaskText(info->keymap, si->interp.mods));
return buf;
log_err(info->keymap->ctx,
"Symbol \"%s\" added to modifier map for multiple modifiers; "
"Using %s, ignoring %s\n",
- KeysymText(new->u.keySym),
+ KeysymText(info->keymap->ctx, new->u.keySym),
ModIndexText(info->keymap, use),
ModIndexText(info->keymap, ignore));
else
log_vrb(info->keymap->ctx, 5,
"Key \"%s\" not found in symbol map; "
"Modifier map entry for %s not updated\n",
- KeysymText(entry->u.keySym),
+ KeysymText(info->keymap->ctx, entry->u.keySym),
ModIndexText(info->keymap, entry->modifier));
return false;
}