diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c index 1d9c5c78..99ff5366 100644 --- a/src/xkbcomp/ast-build.c +++ b/src/xkbcomp/ast-build.c @@ -511,7 +511,7 @@ IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge) incl->modifier = extra_data; incl->next_incl = NULL; - if (nextop == '|') + if (nextop == MERGE_AUGMENT_PREFIX) merge = MERGE_AUGMENT; else merge = MERGE_OVERRIDE; diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c index 96e17755..620b2f4f 100644 --- a/src/xkbcomp/include.c +++ b/src/xkbcomp/include.c @@ -166,7 +166,7 @@ ParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn, /* Set up the next file for the next call, if any. */ if (*nextop_rtrn == '\0') *str_inout = NULL; - else if (*nextop_rtrn == '|' || *nextop_rtrn == '+') + else if (is_merge_mode_prefix(*nextop_rtrn)) *str_inout = next; else return false; diff --git a/src/xkbcomp/include.h b/src/xkbcomp/include.h index 5a5d3315..bcbaeaab 100644 --- a/src/xkbcomp/include.h +++ b/src/xkbcomp/include.h @@ -30,6 +30,12 @@ /* Reasonable threshold, with plenty of margin for keymaps in the wild */ #define INCLUDE_MAX_DEPTH 15 +#define MERGE_OVERRIDE_PREFIX '+' +#define MERGE_AUGMENT_PREFIX '|' +#define MERGE_DEFAULT_PREFIX MERGE_OVERRIDE_PREFIX +#define is_merge_mode_prefix(ch) \ + ((ch) == MERGE_OVERRIDE_PREFIX || (ch) == MERGE_AUGMENT_PREFIX) + bool ParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn, char *nextop_rtrn, char **extra_data); diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c index e5c54ff1..934acbb7 100644 --- a/src/xkbcomp/rules.c +++ b/src/xkbcomp/rules.c @@ -810,7 +810,8 @@ append_expanded_kccgst_value(struct matcher *m, struct scanner *s, pfx = sfx = 0; /* Check for prefix. */ - if (str[i] == '(' || str[i] == '+' || str[i] == '|' || + if (str[i] == '(' || + is_merge_mode_prefix(str[i]) || str[i] == '_' || str[i] == '-') { pfx = str[i]; if (str[i] == '(') sfx = ')'; @@ -895,9 +896,9 @@ append_expanded_kccgst_value(struct matcher *m, struct scanner *s, */ ch = (darray_empty(expanded) ? '\0' : darray_item(expanded, 0)); - expanded_plus = (ch == '+' || ch == '|'); + expanded_plus = is_merge_mode_prefix(ch); ch = (darray_empty(*to) ? '\0' : darray_item(*to, 0)); - to_plus = (ch == '+' || ch == '|'); + to_plus = is_merge_mode_prefix(ch); if (expanded_plus || darray_empty(*to)) darray_appends_nullterminate(*to, expanded.item, expanded.size);