* Daniel Stone <daniel@fooishbar.org>
*/
+#include "config.h"
+
#include "xkbcomp-priv.h"
#include "rules.h"
compile_keymap_file(struct xkb_keymap *keymap, XkbFile *file)
{
if (file->file_type != FILE_TYPE_KEYMAP) {
- log_err(keymap->ctx,
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Cannot compile a %s file alone into a keymap\n",
xkb_file_type_to_string(file->file_type));
return false;
}
if (!CompileKeymap(file, keymap, MERGE_OVERRIDE)) {
- log_err(keymap->ctx,
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Failed to compile keymap\n");
return false;
}
struct xkb_component_names kccgst;
XkbFile *file;
- log_dbg(keymap->ctx,
+ log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Compiling from RMLVO: rules '%s', model '%s', layout '%s', "
"variant '%s', options '%s'\n",
rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant,
ok = xkb_components_from_rules(keymap->ctx, rmlvo, &kccgst);
if (!ok) {
- log_err(keymap->ctx,
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Couldn't look up rules '%s', model '%s', layout '%s', "
"variant '%s', options '%s'\n",
rmlvo->rules, rmlvo->model, rmlvo->layout, rmlvo->variant,
return false;
}
- log_dbg(keymap->ctx,
+ log_dbg(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Compiling from KcCGST: keycodes '%s', types '%s', "
"compat '%s', symbols '%s'\n",
kccgst.keycodes, kccgst.types, kccgst.compat, kccgst.symbols);
free(kccgst.symbols);
if (!file) {
- log_err(keymap->ctx,
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
"Failed to generate parsed XKB file from components\n");
return false;
}
}
static bool
-text_v1_keymap_new_from_string(struct xkb_keymap *keymap, const char *string)
-{
- bool ok;
- XkbFile *xkb_file;
-
- xkb_file = XkbParseString(keymap->ctx, string, "(input string)");
- if (!xkb_file) {
- log_err(keymap->ctx, "Failed to parse input xkb string\n");
- return NULL;
- }
-
- ok = compile_keymap_file(keymap, xkb_file);
- FreeXkbFile(xkb_file);
- return ok;
-}
-
-static bool
-text_v1_keymap_new_from_buffer(struct xkb_keymap *keymap,
- const char *buffer, size_t length)
+text_v1_keymap_new_from_string(struct xkb_keymap *keymap,
+ const char *string, size_t len)
{
bool ok;
XkbFile *xkb_file;
- char *buf;
- buf = malloc(length + 2);
- if (!buf) {
- log_err(keymap->ctx, "Cannot allocate memory for keymap\n");
- return NULL;
- }
-
- /* yy_scan_buffer requires two terminating zero bytes */
- memcpy(buf, buffer, length);
- buf[length] = 0;
- buf[length + 1] = 0;
-
- xkb_file = XkbParseBuffer(keymap->ctx, buf, length + 2, "input");
+ xkb_file = XkbParseString(keymap->ctx, string, len, "(input string)", NULL);
if (!xkb_file) {
- log_err(keymap->ctx, "Failed to parse input xkb file\n");
- free(buf);
- return NULL;
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
+ "Failed to parse input xkb string\n");
+ return false;
}
ok = compile_keymap_file(keymap, xkb_file);
FreeXkbFile(xkb_file);
- free(buf);
return ok;
}
xkb_file = XkbParseFile(keymap->ctx, file, "(unknown file)", NULL);
if (!xkb_file) {
- log_err(keymap->ctx, "Failed to parse input xkb file\n");
+ log_err(keymap->ctx, XKB_LOG_MESSAGE_NO_ID,
+ "Failed to parse input xkb file\n");
return false;
}
const struct xkb_keymap_format_ops text_v1_keymap_format_ops = {
.keymap_new_from_names = text_v1_keymap_new_from_names,
.keymap_new_from_string = text_v1_keymap_new_from_string,
- .keymap_new_from_buffer = text_v1_keymap_new_from_buffer,
.keymap_new_from_file = text_v1_keymap_new_from_file,
.keymap_get_as_string = text_v1_keymap_get_as_string,
};