Fix FTBFS

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
This commit is contained in:
Igor Gnatenko 2016-12-08 21:38:35 +01:00
parent bdfe3d4450
commit abeacb8dd9
8 changed files with 224 additions and 17 deletions

View File

@ -0,0 +1,60 @@
From 416adba8c000bd2a70efc881283249d03a56553b Mon Sep 17 00:00:00 2001
From: Paul LeoNerd Evans <leonerd@leonerd.org.uk>
Date: Tue, 29 Dec 2015 12:37:19 +0000
Subject: [PATCH 1/7] Correct handling of ASCII NUL to imply Ctrl-Space
---
t/02getkey.c | 10 +++++++++-
termkey.c | 8 +++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/t/02getkey.c b/t/02getkey.c
index 279a598..258c2e3 100644
--- a/t/02getkey.c
+++ b/t/02getkey.c
@@ -6,7 +6,7 @@ int main(int argc, char *argv[])
TermKey *tk;
TermKeyKey key;
- plan_tests(31);
+ plan_tests(35);
tk = termkey_new_abstract("vt100", 0);
@@ -69,6 +69,14 @@ int main(int argc, char *argv[])
is_int(key.code.sym, TERMKEY_SYM_ESCAPE, "key.code.sym after Ctrl-Escape");
is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers after Ctrl-Escape");
+ termkey_push_bytes(tk, "\0", 1);
+
+ is_int(termkey_getkey(tk, &key), TERMKEY_RES_KEY, "getkey yields RES_KEY after Ctrl-Space");
+
+ is_int(key.type, TERMKEY_TYPE_UNICODE, "key.type after Ctrl-Space");
+ is_int(key.code.codepoint, ' ', "key.code.codepoint after Ctrl-Space");
+ is_int(key.modifiers, TERMKEY_KEYMOD_CTRL, "key.modifiers after Ctrl-Space");
+
termkey_destroy(tk);
return exit_status();
diff --git a/termkey.c b/termkey.c
index 448df86..a88e6c2 100644
--- a/termkey.c
+++ b/termkey.c
@@ -729,7 +729,13 @@ static TermKeyResult parse_utf8(const unsigned char *bytes, size_t len, long *cp
static void emit_codepoint(TermKey *tk, long codepoint, TermKeyKey *key)
{
- if(codepoint < 0x20) {
+ if(codepoint == 0) {
+ // ASCII NUL = Ctrl-Space
+ key->type = TERMKEY_TYPE_KEYSYM;
+ key->code.sym = TERMKEY_SYM_SPACE;
+ key->modifiers = TERMKEY_KEYMOD_CTRL;
+ }
+ else if(codepoint < 0x20) {
// C0 range
key->code.codepoint = 0;
key->modifiers = 0;
--
2.11.0

View File

@ -0,0 +1,26 @@
From 69d5e2d1451d7f2114d4e46dc60eb731eb721c83 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Thu, 8 Dec 2016 21:05:10 +0100
Subject: [PATCH 1/2] build: take into account CFLAGS/LDFLAGS for tests
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 58ba9b3..67da0fe 100644
--- a/Makefile
+++ b/Makefile
@@ -83,7 +83,7 @@ demo-glib: $(LIBRARY) demo-glib.lo
$(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^ $(call pkgconfig, glib-2.0 --libs)
t/%.t: t/%.c $(LIBRARY) t/taplib.lo
- $(LIBTOOL) --mode=link --tag=CC $(CC) -o $@ $^
+ $(LIBTOOL) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
t/taplib.lo: t/taplib.c
$(LIBTOOL) --mode=compile --tag=CC $(CC) $(CFLAGS) -o $@ -c $^
--
2.11.0

View File

@ -0,0 +1,38 @@
From e044a1603ec1d30e7b8cc765598c3160c857c367 Mon Sep 17 00:00:00 2001
From: Paul LeoNerd Evans <leonerd@leonerd.org.uk>
Date: Tue, 27 Sep 2016 23:18:20 +0100
Subject: [PATCH 2/7] =?UTF-8?q?Bugfix=20for=20keypad=20mode=20switching=20?=
=?UTF-8?q?unibilium/TI=20driver=20(thanks=20P=C5=99emysl=20Janouch)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
driver-ti.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/driver-ti.c b/driver-ti.c
index d827bdf..d678c12 100644
--- a/driver-ti.c
+++ b/driver-ti.c
@@ -239,7 +239,7 @@ static int load_terminfo(TermKeyTI *ti, const char *term)
* time we want to use it
*/
#ifdef HAVE_UNIBILIUM
- const char *keypad_xmit = unibi_get_str(unibi, unibi_pkey_xmit);
+ const char *keypad_xmit = unibi_get_str(unibi, unibi_keypad_xmit);
#endif
if(keypad_xmit)
@@ -248,7 +248,7 @@ static int load_terminfo(TermKeyTI *ti, const char *term)
ti->start_string = NULL;
#ifdef HAVE_UNIBILIUM
- const char *keypad_local = unibi_get_str(unibi, unibi_pkey_local);
+ const char *keypad_local = unibi_get_str(unibi, unibi_keypad_local);
#endif
if(keypad_local)
--
2.11.0

View File

@ -0,0 +1,24 @@
From 0f9ae3282a20e5877c5e8884d749559dc9d204f2 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Date: Thu, 8 Dec 2016 21:09:03 +0100
Subject: [PATCH 2/2] include <stdlib.h> for putenv()
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
---
t/05read.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/05read.c b/t/05read.c
index 073c43d..c9bbe93 100644
--- a/t/05read.c
+++ b/t/05read.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <errno.h>
+#include <stdlib.h>
#include <unistd.h>
#include "../termkey.h"
#include "taplib.h"
--
2.11.0

View File

@ -0,0 +1,35 @@
From fa0a5ea3996a09487924f072afa148d81bf6c53f Mon Sep 17 00:00:00 2001
From: Paul LeoNerd Evans <leonerd@leonerd.org.uk>
Date: Tue, 11 Oct 2016 21:30:36 +0100
Subject: [PATCH 3/7] Endian fix for unicode keys (thanks jamessan)
---
termkey.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/termkey.c b/termkey.c
index a88e6c2..b520b73 100644
--- a/termkey.c
+++ b/termkey.c
@@ -799,15 +799,15 @@ void termkey_canonicalise(TermKey *tk, TermKeyKey *key)
int flags = tk->canonflags;
if(flags & TERMKEY_CANON_SPACESYMBOL) {
- if(key->type == TERMKEY_TYPE_UNICODE && key->code.number == 0x20) {
+ if(key->type == TERMKEY_TYPE_UNICODE && key->code.codepoint == 0x20) {
key->type = TERMKEY_TYPE_KEYSYM;
key->code.sym = TERMKEY_SYM_SPACE;
}
}
else {
if(key->type == TERMKEY_TYPE_KEYSYM && key->code.sym == TERMKEY_SYM_SPACE) {
- key->type = TERMKEY_TYPE_UNICODE;
- key->code.number = 0x20;
+ key->type = TERMKEY_TYPE_UNICODE;
+ key->code.codepoint = 0x20;
fill_utf8(key);
}
}
--
2.11.0

View File

@ -0,0 +1,23 @@
From 34058046142167cb44260341c500af8988eff618 Mon Sep 17 00:00:00 2001
From: Paul LeoNerd Evans <leonerd@leonerd.org.uk>
Date: Tue, 11 Oct 2016 21:38:16 +0100
Subject: [PATCH 4/7] Include <unistd.h> for write+pipe (thanks jamessan)
---
t/05read.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/05read.c b/t/05read.c
index a76cd0a..073c43d 100644
--- a/t/05read.c
+++ b/t/05read.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <errno.h>
+#include <unistd.h>
#include "../termkey.h"
#include "taplib.h"
--
2.11.0

View File

@ -1,9 +0,0 @@
diff -uNr libtermkey-0.18.orig/t/05read.c libtermkey-0.18/t/05read.c
--- libtermkey-0.18.orig/t/05read.c 2015-10-06 23:52:28.000000000 +0200
+++ libtermkey-0.18/t/05read.c 2016-04-14 14:37:56.533341783 +0200
@@ -1,4 +1,5 @@
#include <stdio.h>
+#include <unistd.h>
#include <errno.h>
#include "../termkey.h"
#include "taplib.h"

View File

@ -5,14 +5,22 @@
Name: lib%{libname}
Version: 0.18
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Library for easy processing of keyboard entry from terminal-based programs
License: MIT
URL: http://www.leonerd.org.uk/code/libtermkey/
Source0: %{url}/%{name}-%{version}.tar.gz
Patch0: fix-test-compile.patch
# All patches are taken from https://github.com/neovim/libtermkey
Patch0001: 0001-Correct-handling-of-ASCII-NUL-to-imply-Ctrl-Space.patch
Patch0002: 0002-Bugfix-for-keypad-mode-switching-unibilium-TI-driver.patch
Patch0003: 0003-Endian-fix-for-unicode-keys-thanks-jamessan.patch
Patch0004: 0004-Include-unistd.h-for-write-pipe-thanks-jamessan.patch
# Non-upstream patches
Patch10: 0001-build-take-into-account-CFLAGS-LDFLAGS-for-tests.patch
Patch11: 0002-include-stdlib.h-for-putenv.patch
BuildRequires: gcc
BuildRequires: make
@ -23,7 +31,7 @@ BuildRequires: pkgconfig(unibilium)
BuildRequires: pkgconfig(tinfo)
%endif
# For tests
BuildRequires: /usr/bin/prove
BuildRequires: %{_bindir}/prove
%description
This library allows easy processing of keyboard entry from terminal-based
@ -39,19 +47,18 @@ Requires: %{name}%{?_isa} = %{version}-%{release}
%prep
%autosetup -p1
echo '#!/bin/sh' > ./configure
chmod +x ./configure
# no need for demos
sed -i -e '/^all:/s/$(DEMOS)//' Makefile
%build
%configure
%make_build PREFIX=%{_prefix} LIBDIR=%{_libdir}
CFLAGS="%{__global_cflags}" LDFLAGS="%{__global_ldflags}" %make_build VERBOSE=1
%install
%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir}
rm -vf %{buildroot}%{_libdir}/*.{a,la}
%check
make test CFLAGS="%{optflags}"
CFLAGS="%{__global_cflags} -D_XOPEN_SOURCE" LDFLAGS="%{__global_ldflags}" make test VERBOSE=1
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
@ -68,5 +75,8 @@ make test CFLAGS="%{optflags}"
%{_mandir}/man7/%{libname}.7*
%changelog
* Thu Dec 08 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.18-2
- Fix FTBFS
* Thu Apr 14 2016 Igor Gnatenko <ignatenko@redhat.com> - 0.18-1
- Initial package