Module Name: src
Committed By: mlelstv
Date: Fri Nov 23 06:31:57 UTC 2018
Modified Files:
src/sbin/wsconsctl: keyboard.c util.c wsconsctl.c wsconsctl.h
Log Message:
When merging entries with the keyboard map, print only the resulting changes.
While here, replace bcopy with standad memcpy.
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sbin/wsconsctl/keyboard.c
cvs rdiff -u -r1.31 -r1.32 src/sbin/wsconsctl/util.c
cvs rdiff -u -r1.18 -r1.19 src/sbin/wsconsctl/wsconsctl.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/wsconsctl/wsconsctl.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/wsconsctl/keyboard.c
diff -u src/sbin/wsconsctl/keyboard.c:1.9 src/sbin/wsconsctl/keyboard.c:1.10
--- src/sbin/wsconsctl/keyboard.c:1.9 Mon Apr 28 20:23:09 2008
+++ src/sbin/wsconsctl/keyboard.c Fri Nov 23 06:31:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: keyboard.c,v 1.9 2008/04/28 20:23:09 martin Exp $ */
+/* $NetBSD: keyboard.c,v 1.10 2018/11/23 06:31:57 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@
#include <err.h>
#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include "wsconsctl.h"
@@ -48,6 +49,9 @@ static struct wskbd_bell_data dfbell;
static struct wscons_keymap mapdata[KS_NUMKEYCODES];
struct wskbd_map_data kbmap = /* used in map_parse.y and in util.c */
{ KS_NUMKEYCODES, mapdata };
+static struct wscons_keymap oldmapdata[KS_NUMKEYCODES];
+static struct wskbd_map_data oldkbmap =
+ { KS_NUMKEYCODES, oldmapdata };
static struct wskbd_keyrepeat_data repeat;
static struct wskbd_keyrepeat_data dfrepeat;
static struct wskbd_scroll_data scroll;
@@ -79,6 +83,29 @@ struct field keyboard_field_tab[] = {
int keyboard_field_tab_len = sizeof(keyboard_field_tab) /
sizeof(keyboard_field_tab[0]);
+static void
+diff_kmap(struct wskbd_map_data *omap, struct wskbd_map_data *nmap)
+{
+ unsigned int u;
+ struct wscons_keymap *op, *np;
+
+ for (u = 0; u < nmap->maplen; u++) {
+ op = omap->map + u;
+ np = nmap->map + u;
+ if (op->command == np->command &&
+ op->group1[0] == np->group1[0] &&
+ op->group1[1] == np->group1[1] &&
+ op->group2[0] == np->group2[0] &&
+ op->group2[1] == np->group2[1]) {
+ np->command = KS_voidSymbol;
+ np->group1[0] = KS_voidSymbol;
+ np->group1[1] = KS_voidSymbol;
+ np->group2[0] = KS_voidSymbol;
+ np->group2[1] = KS_voidSymbol;
+ }
+ }
+}
+
void
keyboard_get_values(int fd)
{
@@ -112,6 +139,7 @@ keyboard_get_values(int fd)
kbmap.maplen = KS_NUMKEYCODES;
if (ioctl(fd, WSKBDIO_GETMAP, &kbmap) < 0)
err(EXIT_FAILURE, "WSKBDIO_GETMAP");
+ memcpy(oldmapdata, mapdata, sizeof(oldmapdata));
}
repeat.which = 0;
@@ -200,7 +228,11 @@ keyboard_put_values(int fd)
if (field_by_value(&kbmap)->flags & FLG_SET) {
if (ioctl(fd, WSKBDIO_SETMAP, &kbmap) < 0)
err(EXIT_FAILURE, "WSKBDIO_SETMAP");
- pr_field(field_by_value(&kbmap), " -> ");
+ if (field_by_value(&kbmap)->flags & FLG_MODIFIED) {
+ diff_kmap(&oldkbmap, &kbmap);
+ pr_field(field_by_value(&kbmap), " +> ");
+ } else
+ pr_field(field_by_value(&kbmap), " -> ");
}
repeat.which = 0;
Index: src/sbin/wsconsctl/util.c
diff -u src/sbin/wsconsctl/util.c:1.31 src/sbin/wsconsctl/util.c:1.32
--- src/sbin/wsconsctl/util.c:1.31 Mon Dec 24 01:20:12 2012
+++ src/sbin/wsconsctl/util.c Fri Nov 23 06:31:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.31 2012/12/24 01:20:12 khorben Exp $ */
+/* $NetBSD: util.c,v 1.32 2018/11/23 06:31:57 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 2006, 2012 The NetBSD Foundation, Inc.
@@ -420,7 +420,7 @@ rd_field(struct field *f, char *val, int
}
}
kbmap.maplen = newkbmap.maplen;
- bcopy(newkbmap.map, kbmap.map,
+ memcpy(kbmap.map, newkbmap.map,
kbmap.maplen * sizeof(struct wscons_keymap));
break;
case FMT_COLOR:
Index: src/sbin/wsconsctl/wsconsctl.c
diff -u src/sbin/wsconsctl/wsconsctl.c:1.18 src/sbin/wsconsctl/wsconsctl.c:1.19
--- src/sbin/wsconsctl/wsconsctl.c:1.18 Mon Aug 25 00:14:46 2008
+++ src/sbin/wsconsctl/wsconsctl.c Fri Nov 23 06:31:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsctl.c,v 1.18 2008/08/25 00:14:46 dholland Exp $ */
+/* $NetBSD: wsconsctl.c,v 1.19 2018/11/23 06:31:57 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -207,8 +207,10 @@ main(int argc, char **argv)
}
rd_field(f, p, do_merge);
f->flags |= FLG_SET;
+ if (do_merge)
+ f->flags |= FLG_MODIFIED;
(*putval)(fd);
- f->flags &= ~FLG_SET;
+ f->flags &= ~(FLG_SET | FLG_MODIFIED);
}
} else {
for (i = 0; i < argc; i++) {
Index: src/sbin/wsconsctl/wsconsctl.h
diff -u src/sbin/wsconsctl/wsconsctl.h:1.12 src/sbin/wsconsctl/wsconsctl.h:1.13
--- src/sbin/wsconsctl/wsconsctl.h:1.12 Mon Dec 24 01:20:44 2012
+++ src/sbin/wsconsctl/wsconsctl.h Fri Nov 23 06:31:57 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: wsconsctl.h,v 1.12 2012/12/24 01:20:44 khorben Exp $ */
+/* $NetBSD: wsconsctl.h,v 1.13 2018/11/23 06:31:57 mlelstv Exp $ */
/*-
* Copyright (c) 1998, 2004, 2012 The NetBSD Foundation, Inc.
@@ -71,6 +71,7 @@ struct field {
#define FLG_DISABLED 0x0010 /* variable is not available */
#define FLG_GET 0x0100 /* read this variable from driver */
#define FLG_SET 0x0200 /* write this variable to driver */
+#define FLG_MODIFIED 0x0400 /* value was merged with += */
int flags;
};