enum merge_mode newMerge;
XkbFile *rtrn;
CompatInfo included;
- bool haveSelf;
- haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL)) {
- haveSelf = true;
- included = *info;
- memset(info, 0, sizeof(CompatInfo));
- }
- else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn,
- &newMerge)) {
- InitCompatInfo(&included, keymap, rtrn->id);
- included.dflt = info->dflt;
- included.dflt.merge = newMerge;
- included.ledDflt.merge = newMerge;
- included.act = info->act;
- HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL) {
- free(included.name);
- included.name = stmt->stmt;
- stmt->stmt = NULL;
- }
- if (info->act != NULL)
- included.act = NULL;
- FreeXKBFile(rtrn);
- }
- else {
+ if (!ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn,
+ &newMerge)) {
info->errorCount += 10;
return false;
}
- if ((stmt->next != NULL) && (included.errorCount < 1)) {
+
+ InitCompatInfo(&included, keymap, rtrn->id);
+ included.dflt = info->dflt;
+ included.dflt.merge = newMerge;
+ included.ledDflt.merge = newMerge;
+ included.act = info->act;
+ HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included);
+ if (stmt->stmt) {
+ free(included.name);
+ included.name = stmt->stmt;
+ stmt->stmt = NULL;
+ }
+ if (info->act)
+ included.act = NULL;
+ FreeXKBFile(rtrn);
+
+ if (stmt->next && included.errorCount < 1) {
IncludeStmt *next;
unsigned op;
CompatInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next) {
- if ((next->file == NULL) && (next->map == NULL)) {
- haveSelf = true;
- MergeIncludedCompatMaps(&included, info, next->merge);
- ClearCompatInfo(info, keymap);
- }
- else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT,
- &rtrn, &op)) {
- InitCompatInfo(&next_incl, keymap, rtrn->id);
- next_incl.file_id = rtrn->id;
- next_incl.dflt = info->dflt;
- next_incl.dflt.file_id = rtrn->id;
- next_incl.dflt.merge = op;
- next_incl.ledDflt.file_id = rtrn->id;
- next_incl.ledDflt.merge = op;
- next_incl.act = info->act;
- HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
- MergeIncludedCompatMaps(&included, &next_incl, op);
- if (info->act != NULL)
- next_incl.act = NULL;
- ClearCompatInfo(&next_incl, keymap);
- FreeXKBFile(rtrn);
- }
- else {
+ for (next = stmt->next; next; next = next->next) {
+ if (!ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT,
+ &rtrn, &op)) {
info->errorCount += 10;
return false;
}
+
+ InitCompatInfo(&next_incl, keymap, rtrn->id);
+ next_incl.file_id = rtrn->id;
+ next_incl.dflt = info->dflt;
+ next_incl.dflt.file_id = rtrn->id;
+ next_incl.dflt.merge = op;
+ next_incl.ledDflt.file_id = rtrn->id;
+ next_incl.ledDflt.merge = op;
+ next_incl.act = info->act;
+ HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
+ MergeIncludedCompatMaps(&included, &next_incl, op);
+ if (info->act != NULL)
+ next_incl.act = NULL;
+ ClearCompatInfo(&next_incl, keymap);
+ FreeXKBFile(rtrn);
}
}
- if (haveSelf)
- *info = included;
- else {
- MergeIncludedCompatMaps(info, &included, newMerge);
- ClearCompatInfo(&included, keymap);
- }
+
+ MergeIncludedCompatMaps(info, &included, newMerge);
+ ClearCompatInfo(&included, keymap);
+
return (info->errorCount == 0);
}
enum merge_mode newMerge;
XkbFile *rtrn;
KeyNamesInfo included;
- bool haveSelf;
- memset(&included, 0, sizeof(included));
-
- haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL)) {
- haveSelf = true;
- included = *info;
- memset(info, 0, sizeof(KeyNamesInfo));
- }
- else if (stmt->file && strcmp(stmt->file, "computed") == 0) {
+ /* XXX: What's that? */
+ if (stmt->file && strcmp(stmt->file, "computed") == 0) {
keymap->flags |= AutoKeyNames;
info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0);
- } /* parse file, store returned info in the xkb struct */
- else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
- &newMerge)) {
- InitKeyNamesInfo(&included, rtrn->id);
- HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL) {
- free(included.name);
- included.name = stmt->stmt;
- stmt->stmt = NULL;
- }
- FreeXKBFile(rtrn);
}
- else {
- info->errorCount += 10; /* XXX: why 10?? */
+
+ if (!ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
+ &newMerge)) {
+ info->errorCount += 10;
return false;
}
- /* Do we have more than one include statement? */
- if ((stmt->next != NULL) && (included.errorCount < 1)) {
+
+ InitKeyNamesInfo(&included, rtrn->id);
+ HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
+ if (stmt->stmt) {
+ free(included.name);
+ included.name = stmt->stmt;
+ stmt->stmt = NULL;
+ }
+ FreeXKBFile(rtrn);
+
+ if (stmt->next && included.errorCount < 1) {
IncludeStmt *next;
unsigned op;
KeyNamesInfo next_incl;
for (next = stmt->next; next != NULL; next = next->next) {
- if ((next->file == NULL) && (next->map == NULL)) {
- haveSelf = true;
- MergeIncludedKeycodes(&included, keymap, info, next->merge);
- ClearKeyNamesInfo(info);
- }
- else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
- &rtrn, &op)) {
- InitKeyNamesInfo(&next_incl, rtrn->id);
- HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
- MergeIncludedKeycodes(&included, keymap, &next_incl, op);
- ClearKeyNamesInfo(&next_incl);
- FreeXKBFile(rtrn);
- }
- else {
- info->errorCount += 10; /* XXX: Why 10?? */
+ if (!ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
+ &rtrn, &op)) {
+ info->errorCount += 10;
ClearKeyNamesInfo(&included);
return false;
}
+
+ InitKeyNamesInfo(&next_incl, rtrn->id);
+ HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
+ MergeIncludedKeycodes(&included, keymap, &next_incl, op);
+ ClearKeyNamesInfo(&next_incl);
+ FreeXKBFile(rtrn);
}
}
- if (haveSelf)
- *info = included;
- else {
- MergeIncludedKeycodes(info, keymap, &included, newMerge);
- ClearKeyNamesInfo(&included);
- }
+
+ MergeIncludedKeycodes(info, keymap, &included, newMerge);
+ ClearKeyNamesInfo(&included);
+
return (info->errorCount == 0);
}
enum merge_mode newMerge;
XkbFile *rtrn;
KeyTypesInfo included;
- bool haveSelf;
- haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL)) {
- haveSelf = true;
- included = *info;
- memset(info, 0, sizeof(KeyTypesInfo));
- }
- else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn,
- &newMerge)) {
- InitKeyTypesInfo(&included, keymap, info, rtrn->id);
- included.dflt.defs.merge = newMerge;
-
- HandleKeyTypesFile(rtrn, keymap, newMerge, &included);
- if (stmt->stmt != NULL) {
- free(included.name);
- included.name = stmt->stmt;
- stmt->stmt = NULL;
- }
- FreeXKBFile(rtrn);
- }
- else {
+ if (!ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn,
+ &newMerge)) {
info->errorCount += 10;
return false;
}
+
+ InitKeyTypesInfo(&included, keymap, info, rtrn->id);
+ included.dflt.defs.merge = newMerge;
+
+ HandleKeyTypesFile(rtrn, keymap, newMerge, &included);
+ if (stmt->stmt) {
+ free(included.name);
+ included.name = stmt->stmt;
+ stmt->stmt = NULL;
+ }
+ FreeXKBFile(rtrn);
+
if ((stmt->next != NULL) && (included.errorCount < 1)) {
IncludeStmt *next;
unsigned op;
KeyTypesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next) {
- if ((next->file == NULL) && (next->map == NULL)) {
- haveSelf = true;
- MergeIncludedKeyTypes(&included, info, next->merge, keymap);
- FreeKeyTypesInfo(info);
- }
- else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES,
- &rtrn, &op)) {
- InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id);
- next_incl.dflt.defs.merge = op;
- HandleKeyTypesFile(rtrn, keymap, op, &next_incl);
- MergeIncludedKeyTypes(&included, &next_incl, op, keymap);
- FreeKeyTypesInfo(&next_incl);
- FreeXKBFile(rtrn);
- }
- else {
+ for (next = stmt->next; next; next = next->next) {
+ if (!ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES,
+ &rtrn, &op)) {
info->errorCount += 10;
FreeKeyTypesInfo(&included);
return false;
}
+
+ InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id);
+ next_incl.dflt.defs.merge = op;
+ HandleKeyTypesFile(rtrn, keymap, op, &next_incl);
+ MergeIncludedKeyTypes(&included, &next_incl, op, keymap);
+ FreeKeyTypesInfo(&next_incl);
+ FreeXKBFile(rtrn);
}
}
- if (haveSelf)
- *info = included;
- else {
- MergeIncludedKeyTypes(info, &included, newMerge, keymap);
- FreeKeyTypesInfo(&included);
- }
+
+ MergeIncludedKeyTypes(info, &included, newMerge, keymap);
+ FreeKeyTypesInfo(&included);
+
return (info->errorCount == 0);
}
IncludeStmt *incl, *first;
char *file, *map, *stmt, *tmp, *extra_data;
char nextop;
- bool haveSelf;
- haveSelf = false;
incl = first = NULL;
file = map = NULL;
tmp = str;
stmt = uDupString(str);
- while ((tmp) && (*tmp))
+ while (tmp && *tmp)
{
- if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data)) {
- if ((file == NULL) && (map == NULL)) {
- if (haveSelf)
- goto BAIL;
- haveSelf = true;
- }
- if (first == NULL)
- first = incl = uTypedAlloc(IncludeStmt);
- else {
- incl->next = uTypedAlloc(IncludeStmt);
- incl = incl->next;
- }
- if (incl) {
- incl->common.stmtType = StmtInclude;
- incl->common.next = NULL;
- incl->merge = merge;
- incl->stmt = NULL;
- incl->file = file;
- incl->map = map;
- incl->modifier = extra_data;
- incl->path = NULL;
- incl->next = NULL;
- }
- else {
- WSGO("Allocation failure in IncludeCreate\n");
- ACTION("Using only part of the include\n");
- break;
- }
- if (nextop == '|')
- merge = MERGE_AUGMENT;
- else
- merge = MERGE_OVERRIDE;
+ if (!XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
+ goto err;
+
+ if (first == NULL) {
+ first = incl = uTypedAlloc(IncludeStmt);
+ } else {
+ incl->next = uTypedAlloc(IncludeStmt);
+ incl = incl->next;
}
- else {
- goto BAIL;
+
+ if (!incl) {
+ WSGO("Allocation failure in IncludeCreate\n");
+ ACTION("Using only part of the include\n");
+ break;
}
+
+ incl->common.stmtType = StmtInclude;
+ incl->common.next = NULL;
+ incl->merge = merge;
+ incl->stmt = NULL;
+ incl->file = file;
+ incl->map = map;
+ incl->modifier = extra_data;
+ incl->path = NULL;
+ incl->next = NULL;
+
+ if (nextop == '|')
+ merge = MERGE_AUGMENT;
+ else
+ merge = MERGE_OVERRIDE;
}
+
if (first)
first->stmt = stmt;
else
free(stmt);
+
return first;
-BAIL:
+err:
ERROR("Illegal include statement \"%s\"\n", stmt);
ACTION("Ignored\n");
FreeInclude(first);
char *tmp, *str, *next;
str = *str_inout;
- if ((*str == '+') || (*str == '|')) {
- *file_rtrn = *map_rtrn = NULL;
- *nextop_rtrn = *str;
- next = str + 1;
+
+ /* search for tokens inside the string */
+ next = strpbrk(str, "|+");
+ if (next) {
+ /* set nextop_rtrn to \0, next to next character */
+ *nextop_rtrn = *next;
+ *next++ = '\0';
}
- else if (*str == '%') {
- *file_rtrn = *map_rtrn = NULL;
- *nextop_rtrn = str[1];
- next = str + 2;
+ else {
+ *nextop_rtrn = '\0';
+ next = NULL;
+ }
+
+ /* search for :, store result in extra_data */
+ tmp = strchr(str, ':');
+ if (tmp != NULL) {
+ *tmp++ = '\0';
+ *extra_data = uDupString(tmp);
}
else {
- /* search for tokens inside the string */
- next = strpbrk(str, "|+");
- if (next) {
- /* set nextop_rtrn to \0, next to next character */
- *nextop_rtrn = *next;
- *next++ = '\0';
- }
- else {
- *nextop_rtrn = '\0';
- next = NULL;
- }
- /* search for :, store result in extra_data */
- tmp = strchr(str, ':');
- if (tmp != NULL) {
- *tmp++ = '\0';
- *extra_data = uDupString(tmp);
- }
- else {
- *extra_data = NULL;
- }
- tmp = strchr(str, '(');
- if (tmp == NULL) {
- *file_rtrn = uDupString(str);
- *map_rtrn = NULL;
- }
- else if (str[0] == '(') {
+ *extra_data = NULL;
+ }
+
+ tmp = strchr(str, '(');
+ if (tmp == NULL) {
+ *file_rtrn = uDupString(str);
+ *map_rtrn = NULL;
+ }
+ else if (str[0] == '(') {
+ free(*extra_data);
+ return false;
+ }
+ else {
+ *tmp++ = '\0';
+ *file_rtrn = uDupString(str);
+ str = tmp;
+ tmp = strchr(str, ')');
+ if ((tmp == NULL) || (tmp[1] != '\0')) {
+ free(*file_rtrn);
free(*extra_data);
return false;
}
- else {
- *tmp++ = '\0';
- *file_rtrn = uDupString(str);
- str = tmp;
- tmp = strchr(str, ')');
- if ((tmp == NULL) || (tmp[1] != '\0')) {
- free(*file_rtrn);
- free(*extra_data);
- return false;
- }
- *tmp++ = '\0';
- *map_rtrn = uDupString(str);
- }
+ *tmp++ = '\0';
+ *map_rtrn = uDupString(str);
}
+
if (*nextop_rtrn == '\0')
*str_inout = NULL;
else if ((*nextop_rtrn == '|') || (*nextop_rtrn == '+'))
*str_inout = next;
else
return false;
+
return true;
}
enum merge_mode newMerge;
XkbFile *rtrn;
SymbolsInfo included;
- bool haveSelf;
-
- haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL)) {
- haveSelf = true;
- included = *info;
- memset(info, 0, sizeof(SymbolsInfo));
- }
- else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_SYMBOLS, &rtrn,
- &newMerge)) {
- InitSymbolsInfo(&included, keymap, rtrn->id);
- included.merge = included.dflt.merge = MERGE_OVERRIDE;
- if (stmt->modifier)
- included.explicit_group = atoi(stmt->modifier) - 1;
- else
- included.explicit_group = info->explicit_group;
- HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL) {
- free(included.name);
- included.name = stmt->stmt;
- stmt->stmt = NULL;
- }
- FreeXKBFile(rtrn);
- }
- else {
+
+ if (!ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_SYMBOLS, &rtrn,
+ &newMerge)) {
info->errorCount += 10;
return false;
}
- if ((stmt->next != NULL) && (included.errorCount < 1)) {
+
+ InitSymbolsInfo(&included, keymap, rtrn->id);
+ included.merge = included.dflt.merge = MERGE_OVERRIDE;
+ if (stmt->modifier)
+ included.explicit_group = atoi(stmt->modifier) - 1;
+ else
+ included.explicit_group = info->explicit_group;
+ HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &included);
+ if (stmt->stmt) {
+ free(included.name);
+ included.name = stmt->stmt;
+ stmt->stmt = NULL;
+ }
+ FreeXKBFile(rtrn);
+
+ if (stmt->next && included.errorCount < 1) {
IncludeStmt *next;
unsigned op;
SymbolsInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next) {
- if ((next->file == NULL) && (next->map == NULL)) {
- haveSelf = true;
- MergeIncludedSymbols(&included, info, next->merge, keymap);
- FreeSymbolsInfo(info);
- }
- else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS,
- &rtrn, &op)) {
- InitSymbolsInfo(&next_incl, keymap, rtrn->id);
- next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
- if (next->modifier)
- next_incl.explicit_group = atoi(next->modifier) - 1;
- else
- next_incl.explicit_group = info->explicit_group;
- HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
- MergeIncludedSymbols(&included, &next_incl, op, keymap);
- FreeSymbolsInfo(&next_incl);
- FreeXKBFile(rtrn);
- }
- else {
+ for (next = stmt->next; next; next = next->next) {
+ if (!ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS,
+ &rtrn, &op)) {
info->errorCount += 10;
FreeSymbolsInfo(&included);
return false;
}
+
+ InitSymbolsInfo(&next_incl, keymap, rtrn->id);
+ next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
+ if (next->modifier)
+ next_incl.explicit_group = atoi(next->modifier) - 1;
+ else
+ next_incl.explicit_group = info->explicit_group;
+ HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
+ MergeIncludedSymbols(&included, &next_incl, op, keymap);
+ FreeSymbolsInfo(&next_incl);
+ FreeXKBFile(rtrn);
}
}
else if (stmt->next) {
info->errorCount += included.errorCount;
}
- if (haveSelf)
- *info = included;
- else {
- MergeIncludedSymbols(info, &included, newMerge, keymap);
- FreeSymbolsInfo(&included);
- }
+
+ MergeIncludedSymbols(info, &included, newMerge, keymap);
+ FreeSymbolsInfo(&included);
+
return (info->errorCount == 0);
}