commit: d3f95465ec2fd1080a1e0a17f24c75b7ef1bce5f
parent fb607204770832bf53d1df09dd723b1167fc185e
Author: Michael Forney <mforney@mforney.org>
Date: Fri, 31 May 2019 01:01:08 -0700
kbd: Fix a few portability issues
Diffstat:
4 files changed, 125 insertions(+), 2 deletions(-)
diff --git a/pkg/kbd/gen.lua b/pkg/kbd/gen.lua
@@ -7,7 +7,7 @@ cflags{
'-I $srcdir/src/libkeymap/keymap',
}
-lib('libcommon.a', 'src/(getfd.c xmalloc.c kbd_error.c)')
+lib('libcommon.a', 'src/(getfd.c xmalloc.c kbd_error.c version.c)')
lib('libfont.a', 'src/(kdfontop.c kdmapop.c loadunimap.c psffontop.c utf8.c)')
lib('libkeymap.a', [[src/libkeymap/(
analyze.c
diff --git a/pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch b/pkg/kbd/patch/0001-Avoid-pointer-arithmetic-on-void.patch
@@ -0,0 +1,61 @@
+From 36ab4890a83ec2347dc1955dd8cc40095e497890 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Tue, 12 Mar 2019 16:45:54 -0700
+Subject: [PATCH] Avoid pointer arithmetic on `void *`
+
+Standard C requires that the pointer operand to the + operator be to a
+complete object type[0], so use a `char *` instead.
+
+[0] http://port70.net/~nsz/c/c11/n1570.html#6.5.6p2
+---
+ src/libkeymap/array.c | 6 +++---
+ src/libkeymap/keymap/array.h | 2 +-
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/libkeymap/array.c b/src/libkeymap/array.c
+index 076c1de..ec175df 100644
+--- a/src/libkeymap/array.c
++++ b/src/libkeymap/array.c
+@@ -54,7 +54,7 @@ int lk_array_exists(struct lk_array *a, unsigned int i)
+ return 0;
+ }
+
+- s = (char *)(a->array + (a->memb * i));
++ s = a->array + (a->memb * i);
+
+ for (k = 0; k < a->memb; k++) {
+ if (s[k] != 0)
+@@ -80,7 +80,7 @@ lk_array_get_ptr(struct lk_array *a, unsigned int i)
+ if (!a || i >= a->total) {
+ return NULL;
+ }
+- ptr = a->array;
++ ptr = (void **)a->array;
+ return *(ptr + i);
+ }
+
+@@ -91,7 +91,7 @@ array_resize(struct lk_array *a, unsigned int i)
+ return -EINVAL;
+
+ if (i >= a->total) {
+- void *tmp = realloc(a->array, a->memb * (i + 1));
++ char *tmp = realloc(a->array, a->memb * (i + 1));
+ if (!tmp)
+ return -ENOMEM;
+
+diff --git a/src/libkeymap/keymap/array.h b/src/libkeymap/keymap/array.h
+index 9894af1..caac6fb 100644
+--- a/src/libkeymap/keymap/array.h
++++ b/src/libkeymap/keymap/array.h
+@@ -6,7 +6,7 @@
+ * @details The array is designed to store an arbitrary number of similar items.
+ */
+ struct lk_array {
+- void *array; /**< Data pointer. */
++ char *array; /**< Data pointer. */
+ size_t memb; /**< One element size. */
+ size_t count; /**< Number of elements. */
+ size_t total; /**< Total number of allocated elements. */
+--
+2.20.1
+
diff --git a/pkg/kbd/patch/0002-Avoid-duplicate-external-definitions-of-progname.patch b/pkg/kbd/patch/0002-Avoid-duplicate-external-definitions-of-progname.patch
@@ -0,0 +1,62 @@
+From 474ee8777d5fd011ec61bd66d42c95c6d99499f9 Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Thu, 30 May 2019 21:37:42 -0700
+Subject: [PATCH] Avoid duplicate external definitions of progname
+
+---
+ src/Makefile.am | 5 +++--
+ src/version.c | 5 +++++
+ src/version.h | 2 +-
+ 3 files changed, 9 insertions(+), 3 deletions(-)
+ create mode 100644 src/version.c
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index d4e0583..1d80cf8 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -39,7 +39,8 @@ EXTRA_DIST = \
+ libcommon_a_SOURCES = \
+ getfd.c getfd.h \
+ xmalloc.c xmalloc.h \
+- kbd_error.c kbd_error.h
++ kbd_error.c kbd_error.h \
++ version.c version.h
+
+ libfont_a_SOURCES = \
+ psf.h psffontop.c psffontop.h \
+@@ -48,7 +49,7 @@ libfont_a_SOURCES = \
+ loadunimap.c loadunimap.h \
+ kdfontop.c kdfontop.h
+
+-ALL_S = nls.h paths.h version.h kbd.h
++ALL_S = nls.h paths.h kbd.h
+
+ chvt_SOURCES = $(ALL_S) chvt.c
+ clrunimap_SOURCES = $(ALL_S) clrunimap.c
+diff --git a/src/version.c b/src/version.c
+new file mode 100644
+index 0000000..29b5161
+--- /dev/null
++++ b/src/version.c
+@@ -0,0 +1,5 @@
++#include "config.h"
++
++#include "version.h"
++
++char *progname;
+diff --git a/src/version.h b/src/version.h
+index 31d1435..4daf24c 100644
+--- a/src/version.h
++++ b/src/version.h
+@@ -5,7 +5,7 @@
+ #include <string.h>
+ #include <stdlib.h>
+
+-char *progname;
++extern char *progname;
+
+ static inline void
+ set_progname(char *name)
+--
+2.20.1
+
diff --git a/pkg/kbd/ver b/pkg/kbd/ver
@@ -1 +1 @@
-2.0.4 r0
+2.0.4 r1