Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/wsconsctl When merging entries with the keyboard map, p...



details:   https://anonhg.NetBSD.org/src/rev/a38baf6e0dff
branches:  trunk
changeset: 994810:a38baf6e0dff
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Fri Nov 23 06:31:57 2018 +0000

description:
When merging entries with the keyboard map, print only the resulting changes.

While here, replace bcopy with standad memcpy.

diffstat:

 sbin/wsconsctl/keyboard.c  |  36 ++++++++++++++++++++++++++++++++++--
 sbin/wsconsctl/util.c      |   4 ++--
 sbin/wsconsctl/wsconsctl.c |   6 ++++--
 sbin/wsconsctl/wsconsctl.h |   3 ++-
 4 files changed, 42 insertions(+), 7 deletions(-)

diffs (134 lines):

diff -r bae2de4ba3a2 -r a38baf6e0dff sbin/wsconsctl/keyboard.c
--- a/sbin/wsconsctl/keyboard.c Thu Nov 22 23:37:31 2018 +0000
+++ b/sbin/wsconsctl/keyboard.c Fri Nov 23 06:31:57 2018 +0000
@@ -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 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 @@
 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 @@
                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 @@
        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;
diff -r bae2de4ba3a2 -r a38baf6e0dff sbin/wsconsctl/util.c
--- a/sbin/wsconsctl/util.c     Thu Nov 22 23:37:31 2018 +0000
+++ b/sbin/wsconsctl/util.c     Fri Nov 23 06:31:57 2018 +0000
@@ -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 @@
                        }
                }
                kbmap.maplen = newkbmap.maplen;
-               bcopy(newkbmap.map, kbmap.map,
+               memcpy(kbmap.map, newkbmap.map,
                    kbmap.maplen * sizeof(struct wscons_keymap));
                break;
        case FMT_COLOR:
diff -r bae2de4ba3a2 -r a38baf6e0dff sbin/wsconsctl/wsconsctl.c
--- a/sbin/wsconsctl/wsconsctl.c        Thu Nov 22 23:37:31 2018 +0000
+++ b/sbin/wsconsctl/wsconsctl.c        Fri Nov 23 06:31:57 2018 +0000
@@ -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 @@
                                }
                                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++) {
diff -r bae2de4ba3a2 -r a38baf6e0dff sbin/wsconsctl/wsconsctl.h
--- a/sbin/wsconsctl/wsconsctl.h        Thu Nov 22 23:37:31 2018 +0000
+++ b/sbin/wsconsctl/wsconsctl.h        Fri Nov 23 06:31:57 2018 +0000
@@ -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 @@
 #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;
 };
 



Home | Main Index | Thread Index | Old Index