Hash :
23598fa1
Author :
Date :
2025-03-25T22:52:06
Enable merge mode “replace” in include statements Previously only the merge modes “override” and “augment” were available in include statements, using the prefix ‘+’ and ‘|’ respectively. While on one hand `replace` include statement can be used in keymap files, on the other hand *rules* files have no way to express the *replace* mode. This commit enables the merge mode “replace” using the prefix `^`. This prefix was chosen due to its similarity with the `XOR` bit operator, which convey *mutual exclusion*. Other candidates: - `!` conveys some kind of higher precedence, akin to CSS `!important`. But it conflicts with the section header `!`, which is a token in the current parser. It would require special handling, not worth it. It also convey the meaning of negation, which is confusing. - `&` has the advantage of not corresponding to a token in the rules parser. `^` seems however to stand out more and it is less likely to trigger erroneous comparison with `|` and `&` bit operators.
/*
* Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
* SPDX-License-Identifier: HPND
*/
#pragma once
#include "ast.h"
/* 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_REPLACE_PREFIX '^'
#define MERGE_DEFAULT_PREFIX MERGE_OVERRIDE_PREFIX
#define is_merge_mode_prefix(ch) \
((ch) == MERGE_OVERRIDE_PREFIX || (ch) == MERGE_AUGMENT_PREFIX || \
(ch) == MERGE_REPLACE_PREFIX)
static const char MERGE_MODE_PREFIXES[] =
{ MERGE_OVERRIDE_PREFIX, MERGE_AUGMENT_PREFIX, MERGE_REPLACE_PREFIX, 0 };
bool
ParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
char *nextop_rtrn, char **extra_data);
FILE *
FindFileInXkbPath(struct xkb_context *ctx, const char *name,
enum xkb_file_type type, char **pathRtrn,
unsigned int *offset);
bool
ExceedsIncludeMaxDepth(struct xkb_context *ctx, unsigned int include_depth);
XkbFile *
ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
enum xkb_file_type file_type);