Keysyms: Fix missing hpYdiaeresis
The handling of keysym name guards (e.g. `#ifndef XK_Ydiaeresis`) was incomplete and led to a missing keysym. Make `sripts/makeheader` more robust to C macros handling.master
parent
1c1542d64f
commit
238d132406
|
@ -3207,6 +3207,7 @@ performance, or use of this material.
|
||||||
#define XKB_KEY_hpmute_asciitilde 0x100000ac
|
#define XKB_KEY_hpmute_asciitilde 0x100000ac
|
||||||
#define XKB_KEY_hplira 0x100000af
|
#define XKB_KEY_hplira 0x100000af
|
||||||
#define XKB_KEY_hpguilder 0x100000be
|
#define XKB_KEY_hpguilder 0x100000be
|
||||||
|
#define XKB_KEY_hpYdiaeresis 0x100000ee
|
||||||
#define XKB_KEY_hpIO 0x100000ee /* deprecated alias for hpYdiaeresis */
|
#define XKB_KEY_hpIO 0x100000ee /* deprecated alias for hpYdiaeresis */
|
||||||
#define XKB_KEY_hplongminus 0x100000f6
|
#define XKB_KEY_hplongminus 0x100000f6
|
||||||
#define XKB_KEY_hpblock 0x100000fc
|
#define XKB_KEY_hpblock 0x100000fc
|
||||||
|
|
|
@ -19,6 +19,9 @@ keysym_entry_pattern = re.compile(
|
||||||
re.VERBOSE,
|
re.VERBOSE,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Match keysym guarded by #ifndef
|
||||||
|
keysym_ifndef_pattern = re.compile(r"^#ifndef\s+(?P<prefix>\w*)XK_(?P<name>\w+)\s*$")
|
||||||
|
|
||||||
# Match remaining XK_ references in the comments, e.g we will replace:
|
# Match remaining XK_ references in the comments, e.g we will replace:
|
||||||
# XF86XK_CamelCaseKernelName _EVDEVK(kernel value)
|
# XF86XK_CamelCaseKernelName _EVDEVK(kernel value)
|
||||||
# #define XKB_KEY_SunCompose 0x0000FF20 /* Same as XK_Multi_key */
|
# #define XKB_KEY_SunCompose 0x0000FF20 /* Same as XK_Multi_key */
|
||||||
|
@ -28,6 +31,10 @@ keysym_entry_pattern = re.compile(
|
||||||
xorgproto_keysym_prefix_pattern = re.compile(r"\b(?P<prefix>\w*)XK_(?!KOREAN\b)")
|
xorgproto_keysym_prefix_pattern = re.compile(r"\b(?P<prefix>\w*)XK_(?!KOREAN\b)")
|
||||||
|
|
||||||
|
|
||||||
|
def make_keysym_name(m: re.Match[str]) -> str:
|
||||||
|
return m.group("prefix") + m.group("name")
|
||||||
|
|
||||||
|
|
||||||
def make_keysym_entry(m: re.Match[str]) -> str:
|
def make_keysym_entry(m: re.Match[str]) -> str:
|
||||||
"""
|
"""
|
||||||
Perform the substitutions
|
Perform the substitutions
|
||||||
|
@ -74,20 +81,49 @@ print(
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
keysyms: set[str] = set()
|
||||||
for path in HEADERS:
|
for path in HEADERS:
|
||||||
|
pending_guarded_keysym: str | None = None
|
||||||
with path.open("rt", encoding="utf-8") as header:
|
with path.open("rt", encoding="utf-8") as header:
|
||||||
for line in header:
|
for line in header:
|
||||||
if "#ifdef" in line or "#ifndef" in line or "#endif" in line:
|
# Duplicate keysym name guard
|
||||||
|
if m := keysym_ifndef_pattern.match(line):
|
||||||
|
if pending_guarded_keysym:
|
||||||
|
raise ValueError(f"Nested #ifndef {pending_guarded_keysym}")
|
||||||
|
pending_guarded_keysym = make_keysym_name(m)
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Ignore C macro #ifdef/#ifndef
|
||||||
|
elif line.startswith("#ifdef") or line.startswith("#ifndef"):
|
||||||
|
if pending_guarded_keysym:
|
||||||
|
raise ValueError(f"Nested C macro {pending_guarded_keysym}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Ignore C macro #endif and check end of keysym name guard
|
||||||
|
elif line.startswith("#endif"):
|
||||||
|
if pending_guarded_keysym:
|
||||||
|
pending_guarded_keysym = None
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Remove #define _OSF_Keysyms and such.
|
# Remove #define _OSF_Keysyms and such.
|
||||||
if "#define _" in line:
|
elif line.startswith("#define _"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Handle a duplicate definition in HPkeysyms.h which kicks in if
|
# Keysym entry: proceed various tests
|
||||||
# it's not already defined.
|
if line.startswith("#") and (m := keysym_entry_pattern.match(line)):
|
||||||
if "XK_Ydiaeresis" in line and "0x100000ee" in line:
|
name = make_keysym_name(m)
|
||||||
|
# Check expected guarded keysym, if relevant
|
||||||
|
if pending_guarded_keysym and name != pending_guarded_keysym:
|
||||||
|
raise ValueError(f"{path}: Malformed keysym name guard: {line}")
|
||||||
|
# Check if name already defined
|
||||||
|
elif name in keysyms:
|
||||||
|
if pending_guarded_keysym:
|
||||||
|
# Ignore guarded keysym
|
||||||
continue
|
continue
|
||||||
|
else:
|
||||||
|
raise ValueError(f"{path}: Unguarded redefinition: {line}")
|
||||||
|
else:
|
||||||
|
keysyms.add(name)
|
||||||
|
|
||||||
# Perform _EVDEV and XK_ substitutions
|
# Perform _EVDEV and XK_ substitutions
|
||||||
line = keysym_entry_pattern.sub(make_keysym_entry, line)
|
line = keysym_entry_pattern.sub(make_keysym_entry, line)
|
||||||
|
|
5614
src/ks_tables.h
5614
src/ks_tables.h
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue