git: b4eab621f246 - main - kbdcontrol.c: make pre-Unicode compatibility conditional

From: Stefan Eßer <se_at_FreeBSD.org>
Date: Tue, 14 Feb 2023 13:15:55 UTC
The branch main has been updated by se:

URL: https://cgit.FreeBSD.org/src/commit/?id=b4eab621f2462574d1836c199dc84c5bdb4f60f7

commit b4eab621f2462574d1836c199dc84c5bdb4f60f7
Author:     Stefan Eßer <se@FreeBSD.org>
AuthorDate: 2023-02-14 12:27:27 +0000
Commit:     Stefan Eßer <se@FreeBSD.org>
CommitDate: 2023-02-14 12:27:27 +0000

    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
---
 usr.sbin/kbdcontrol/kbdcontrol.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

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(