aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Eßer <se@FreeBSD.org>2023-02-14 12:27:27 +0000
committerStefan Eßer <se@FreeBSD.org>2023-02-14 12:27:27 +0000
commitb4eab621f2462574d1836c199dc84c5bdb4f60f7 (patch)
treefdc5fa57666cff7161b1f06e620f0e4dabef4a8b
parent31a2528768894c46751974b7efbbfb3db0f01c5e (diff)
downloadsrc-b4eab621f2462574d1836c199dc84c5bdb4f60f7.tar.gz
src-b4eab621f2462574d1836c199dc84c5bdb4f60f7.zip
kbdcontrol.c: make pre-Unicode compatibility conditional
Support for the full range of Unicode character codes has been added to the main keymap back in 2009, with compatibility shims added in 2011 (to support an older kbdcontrol command on a new kernel during an upgrade from FreeBSD-8 to FreeBSD-9). Unicode support for accented characters that are reached via dead key combinations has been added just recently, again with compatibility shims to allow all combinations of old/new kernel and old/new kbdcontrol command to load and display the keymaps including the dead key table. (But full Unicode in the dead key table requires both a new kernel and kbdcontrol command.) This commit makes the compatibility shims depend on the respective compatibility ioctls (OGIO_KEYMAP, OPIO_KEYMAP, OGIO_DEADKEYMAP, and OPIO_DEADKEYMAP) being defined in sys/kbio.h. This is true for all of them in 13-STABLE, none in 12-STABLE (as of now), and will become optional due to a follow-up commit to sys/kbio.h in -CURRENT. This commit is the only part of review D38465 that should be merged back to 12-STABLE and 13-STABLE. MFC after: 1 month
-rw-r--r--usr.sbin/kbdcontrol/kbdcontrol.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c
index 725d62a7bfe6..44f34f9a4f3a 100644
--- a/usr.sbin/kbdcontrol/kbdcontrol.c
+++ b/usr.sbin/kbdcontrol/kbdcontrol.c
@@ -818,6 +818,7 @@ add_keymap_path(const char *path)
STAILQ_INSERT_TAIL(&pathlist, pe, next);
}
+#ifdef OPIO_DEADKEYMAP
static void
to_old_accentmap(accentmap_t *from, oaccentmap_t *to)
{
@@ -832,13 +833,16 @@ to_old_accentmap(accentmap_t *from, oaccentmap_t *to)
}
}
}
+#endif /* OPIO_DEADKEYMAP */
static void
load_keymap(char *opt, int dumponly)
{
keymap_t keymap;
accentmap_t accentmap;
+#ifdef OPIO_DEADKEYMAP
oaccentmap_t oaccentmap;
+#endif /* OPIO_DEADKEYMAP */
struct pathent *pe;
FILE *file;
int j;
@@ -898,8 +902,11 @@ load_keymap(char *opt, int dumponly)
}
if ((accentmap.n_accs > 0)
&& (ioctl(0, PIO_DEADKEYMAP, &accentmap) < 0)) {
+#ifdef OPIO_DEADKEYMAP
to_old_accentmap(&accentmap, &oaccentmap);
- if (ioctl(0, OPIO_DEADKEYMAP, &oaccentmap) < 0) {
+ if (ioctl(0, OPIO_DEADKEYMAP, &oaccentmap) < 0)
+#endif /* OGIO_DEADKEYMAP */
+ {
warn("setting accentmap");
fclose(file);
return;
@@ -907,6 +914,7 @@ load_keymap(char *opt, int dumponly)
}
}
+#ifdef OPIO_DEADKEYMAP
static void
to_new_accentmap(oaccentmap_t *from, accentmap_t *to)
{
@@ -921,21 +929,26 @@ to_new_accentmap(oaccentmap_t *from, accentmap_t *to)
}
}
}
+#endif /* OPIO_DEADKEYMAP */
static void
print_keymap(void)
{
keymap_t keymap;
accentmap_t accentmap;
+#ifdef OGIO_DEADKEYMAP
oaccentmap_t oaccentmap;
+#endif /* OPIO_DEADKEYMAP */
int i;
if (ioctl(0, GIO_KEYMAP, &keymap) < 0)
err(1, "getting keymap");
if (ioctl(0, GIO_DEADKEYMAP, &accentmap) < 0) {
+#ifdef OGIO_DEADKEYMAP
if (ioctl(0, OGIO_DEADKEYMAP, &oaccentmap) == 0)
to_new_accentmap(&oaccentmap, &accentmap);
else
+#endif /* OGIO_DEADKEYMAP */
memset(&accentmap, 0, sizeof(accentmap));
}
printf(