Merge pull request #17395 from keszybz/hwdb-drop-quotes

hwdb: drop quotes from XKB_FIXED_*= properties
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2020-10-21 11:34:39 +02:00 committed by GitHub
commit 9d7b11fdc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 35 deletions

View File

@ -72,14 +72,14 @@
# A device with a fixed keyboard layout that must not be changed by
# the desktop environment may specify that layout as:
# XKB_FIXED_LAYOUT="us"
# XKB_FIXED_VARIANT=""
# XKB_FIXED_LAYOUT=us
# XKB_FIXED_VARIANT=
# Examples of such devices: the Yubikey or other key-code generating
# devices.
# A device where the scan code to key code mapping is insufficient and
# requires a special key code to symbol configuration may specify that with:
# XKB_FIXED_MODEL="xkbmodel"
# XKB_FIXED_MODEL=xkbmodel
# Examples of such devices: Chromebooks where the top row is used for both
# media and F1-F10 keys.
@ -1796,8 +1796,8 @@ evdev:input:b0003v1050p0111:*
evdev:input:b0003v1050p0116:*
# OKE Electron Company USB barcode reader
evdev:input:b0003v05FEp1010:*
XKB_FIXED_LAYOUT="us"
XKB_FIXED_VARIANT=""
XKB_FIXED_LAYOUT=us
XKB_FIXED_VARIANT=
######################### LACK OF MODIFIER LEDS ############################
# This section lists keyboard which do not have their own LEDs for some
@ -1846,4 +1846,4 @@ evdev:atkbd:dmi:bvn*:bvr*:bd*:svnLENOVO:pn*:pvrThinkPadX1Carbon3rd:*
# Chromebooks
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnHewlett-Packard*:pnFalco:*
evdev:atkbd:dmi:bvn*:bvr*:bd*:svnAcer*:pnPeppy:*
XKB_FIXED_MODEL="chromebook"
XKB_FIXED_MODEL=chromebook

View File

@ -32,7 +32,7 @@ try:
from pyparsing import (Word, White, Literal, ParserElement, Regex, LineEnd,
OneOrMore, Combine, Or, Optional, Suppress, Group,
nums, alphanums, printables,
stringEnd, pythonStyleComment, QuotedString,
stringEnd, pythonStyleComment,
ParseBaseException)
except ImportError:
print('pyparsing is not available')
@ -54,7 +54,6 @@ EOL = LineEnd().suppress()
EMPTYLINE = LineEnd()
COMMENTLINE = pythonStyleComment + EOL
INTEGER = Word(nums)
STRING = QuotedString('"')
REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
SIGNED_REAL = Combine(Optional(Word('-+')) + REAL)
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
@ -94,7 +93,8 @@ def hwdb_grammar():
matchline = (matchline_typed | matchline_general) + EOL
propertyline = (White(' ', exact=1).suppress() +
Combine(UDEV_TAG - '=' - Word(alphanums + '_=:@*.!-;, "') - Optional(pythonStyleComment)) +
Combine(UDEV_TAG - '=' - Optional(Word(alphanums + '_=:@*.!-;, "'))
- Optional(pythonStyleComment)) +
EOL)
propertycomment = White(' ', exact=1) + pythonStyleComment + EOL
@ -114,6 +114,7 @@ def property_grammar():
dpi_setting = (Optional('*')('DEFAULT') + INTEGER('DPI') + Suppress('@') + INTEGER('HZ'))('SETTINGS*')
mount_matrix_row = SIGNED_REAL + ',' + SIGNED_REAL + ',' + SIGNED_REAL
mount_matrix = (mount_matrix_row + ';' + mount_matrix_row + ';' + mount_matrix_row)('MOUNT_MATRIX')
xkb_setting = Optional(Word(alphanums + '+-/@._'))
props = (('MOUSE_DPI', Group(OneOrMore(dpi_setting))),
('MOUSE_WHEEL_CLICK_ANGLE', INTEGER),
@ -138,9 +139,9 @@ def property_grammar():
('POINTINGSTICK_CONST_ACCEL', REAL),
('ID_INPUT_JOYSTICK_INTEGRATION', Or(('internal', 'external'))),
('ID_INPUT_TOUCHPAD_INTEGRATION', Or(('internal', 'external'))),
('XKB_FIXED_LAYOUT', STRING),
('XKB_FIXED_VARIANT', STRING),
('XKB_FIXED_MODEL', STRING),
('XKB_FIXED_LAYOUT', xkb_setting),
('XKB_FIXED_VARIANT', xkb_setting),
('XKB_FIXED_MODEL', xkb_setting),
('KEYBOARD_LED_NUMLOCK', Literal('0')),
('KEYBOARD_LED_CAPSLOCK', Literal('0')),
('ACCEL_MOUNT_MATRIX', mount_matrix),

View File

@ -105,12 +105,10 @@ static struct trie_node *node_lookup(const struct trie_node *node, uint8_t c) {
}
static void trie_node_cleanup(struct trie_node *node) {
size_t i;
if (!node)
return;
for (i = 0; i < node->children_count; i++)
for (size_t i = 0; i < node->children_count; i++)
trie_node_cleanup(node->children[i].child);
free(node->children);
free(node->values);
@ -191,10 +189,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
static int trie_insert(struct trie *trie, struct trie_node *node, const char *search,
const char *key, const char *value,
const char *filename, uint16_t file_priority, uint32_t line_number, bool compat) {
size_t i = 0;
int r = 0;
for (;;) {
for (size_t i = 0;; i++) {
size_t p;
uint8_t c;
struct trie_node *child;
@ -273,7 +270,6 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
}
node = child;
i++;
}
}
@ -289,20 +285,17 @@ struct trie_f {
/* calculate the storage space for the nodes, children arrays, value arrays */
static void trie_store_nodes_size(struct trie_f *trie, struct trie_node *node, bool compat) {
uint64_t i;
for (i = 0; i < node->children_count; i++)
for (uint64_t i = 0; i < node->children_count; i++)
trie_store_nodes_size(trie, node->children[i].child, compat);
trie->strings_off += sizeof(struct trie_node_f);
for (i = 0; i < node->children_count; i++)
for (uint64_t i = 0; i < node->children_count; i++)
trie->strings_off += sizeof(struct trie_child_entry_f);
for (i = 0; i < node->values_count; i++)
for (uint64_t i = 0; i < node->values_count; i++)
trie->strings_off += compat ? sizeof(struct trie_value_entry_f) : sizeof(struct trie_value_entry2_f);
}
static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, bool compat) {
uint64_t i;
struct trie_node_f n = {
.prefix_off = htole64(trie->strings_off + node->prefix_off),
.children_count = node->children_count,
@ -318,7 +311,7 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, boo
}
/* post-order recursion */
for (i = 0; i < node->children_count; i++) {
for (uint64_t i = 0; i < node->children_count; i++) {
int64_t child_off;
child_off = trie_store_nodes(trie, node->children[i].child, compat);
@ -343,7 +336,7 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, boo
}
/* append values array */
for (i = 0; i < node->values_count; i++) {
for (uint64_t i = 0; i < node->values_count; i++) {
struct trie_value_entry2_f v = {
.key_off = htole64(trie->strings_off + node->values[i].key_off),
.value_off = htole64(trie->strings_off + node->values[i].value_off),
@ -447,7 +440,7 @@ static int insert_data(struct trie *trie, char **match_list, char *line, const c
value = strchr(line, '=');
if (!value)
return log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
"Key-value pair expected but got \"%s\", ignoring", line);
"Key-value pair expected but got \"%s\", ignoring.", line);
value[0] = '\0';
value++;
@ -456,10 +449,9 @@ static int insert_data(struct trie *trie, char **match_list, char *line, const c
while (isblank(line[0]) && isblank(line[1]))
line++;
if (isempty(line + 1) || isempty(value))
if (isempty(line + 1))
return log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
"Empty %s in \"%s=%s\", ignoring",
isempty(line + 1) ? "key" : "value",
"Empty key in \"%s=%s\", ignoring.",
line, value);
STRV_FOREACH(entry, match_list)
@ -494,7 +486,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
if (r == 0)
break;
++line_number;
line_number ++;
/* comment line */
if (line[0] == '#')
@ -518,7 +510,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
if (line[0] == ' ') {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
"Match expected but got indented property \"%s\", ignoring line", line);
"Match expected but got indented property \"%s\", ignoring line.", line);
break;
}
@ -534,7 +526,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
case HW_MATCH:
if (len == 0) {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
"Property expected, ignoring record with no properties");
"Property expected, ignoring record with no properties.");
state = HW_NONE;
match_list = strv_free(match_list);
break;
@ -566,7 +558,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
if (line[0] != ' ') {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
"Property or empty line expected, got \"%s\", ignoring record", line);
"Property or empty line expected, got \"%s\", ignoring record.", line);
state = HW_NONE;
match_list = strv_free(match_list);
break;
@ -581,7 +573,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
if (state == HW_MATCH)
log_syntax(NULL, LOG_WARNING, filename, line_number, 0,
"Property expected, ignoring record with no properties");
"Property expected, ignoring record with no properties.");
return r;
}