Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #8208 'Clean up dependency patches'
closes #6659
- Loading branch information
Showing
7 changed files
with
254 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
cmake_minimum_required(VERSION 2.8.7) | ||
project(libtermkey) | ||
|
||
add_definitions(-D _CRT_SECURE_NO_WARNINGS) | ||
add_definitions(-DHAVE_UNIBILIUM) | ||
if(NOT MSVC) | ||
add_definitions(-std=c99) | ||
endif() | ||
|
||
include_directories(${PROJECT_BINARY_DIR}/t) | ||
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS}) | ||
|
||
add_library(termkey termkey.c driver-csi.c driver-ti.c) | ||
set_target_properties(termkey PROPERTIES | ||
PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/termkey.h) | ||
target_link_libraries(termkey ${UNIBILIUM_LIBRARIES}) | ||
|
||
include(GNUInstallDirs) | ||
install(TARGETS termkey | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
|
||
enable_testing() | ||
file(GLOB TESTSOURCES "t/[0-9]*.c") | ||
foreach(f ${TESTSOURCES}) | ||
get_filename_component(t ${f} NAME_WE) | ||
if(${t} STREQUAL 05read) | ||
continue() | ||
endif() | ||
|
||
add_executable("test_${t}" ${f} t/taplib.c) | ||
target_link_libraries("test_${t}" termkey) | ||
add_test("${t}" "test_${t}") | ||
endforeach() |
170 changes: 170 additions & 0 deletions
170
third-party/patches/libtermkey-Add-support-for-Windows.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
From fbe91a958816d85fa93665eb8f7a7a8e05eb9650 Mon Sep 17 00:00:00 2001 | ||
From: Rui Abreu Ferreira <raf-ep@gmx.com> | ||
Date: Tue, 5 Apr 2016 00:12:41 +0100 | ||
Subject: [PATCH] Add support for Windows | ||
|
||
Ported termkey for windows. | ||
|
||
- The TERMKEY_FLAG_NOTERMIOS is ignore in Windows, since there is no termios. | ||
- The termkey_waitkey() function is not implemented in windows, since there | ||
is no poll() alternative. | ||
- The CMake recipe only supports unibilium, not curses. | ||
--- | ||
driver-ti.c | 8 +++++++- | ||
termkey-internal.h | 11 ++++++++++- | ||
termkey.c | 22 ++++++++++++++++++---- | ||
3 files changed, 35 insertions(+), 6 deletions(-) | ||
|
||
diff --git a/driver-ti.c b/driver-ti.c | ||
index e673ab7..f5f8052 100644 | ||
--- a/driver-ti.c | ||
+++ b/driver-ti.c | ||
@@ -17,7 +17,9 @@ | ||
#include <ctype.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
-#include <unistd.h> | ||
+#ifndef _WIN32 | ||
+# include <unistd.h> | ||
+#endif | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
|
||
@@ -338,8 +340,10 @@ static int start_driver(TermKey *tk, void *info) | ||
if(fstat(tk->fd, &statbuf) == -1) | ||
return 0; | ||
|
||
+#ifndef _WIN32 | ||
if(S_ISFIFO(statbuf.st_mode)) | ||
return 1; | ||
+#endif | ||
|
||
// Can't call putp or tputs because they suck and don't give us fd control | ||
len = strlen(start_string); | ||
@@ -367,8 +371,10 @@ static int stop_driver(TermKey *tk, void *info) | ||
if(fstat(tk->fd, &statbuf) == -1) | ||
return 0; | ||
|
||
+#ifndef _WIN32 | ||
if(S_ISFIFO(statbuf.st_mode)) | ||
return 1; | ||
+#endif | ||
|
||
/* The terminfo database will contain keys in application cursor key mode. | ||
* We may need to enable that mode | ||
diff --git a/termkey-internal.h b/termkey-internal.h | ||
index 52829b3..b796729 100644 | ||
--- a/termkey-internal.h | ||
+++ b/termkey-internal.h | ||
@@ -4,7 +4,14 @@ | ||
#include "termkey.h" | ||
|
||
#include <stdint.h> | ||
-#include <termios.h> | ||
+#ifndef _WIN32 | ||
+# include <termios.h> | ||
+#endif | ||
+ | ||
+#ifdef _MSC_VER | ||
+#include <BaseTsd.h> | ||
+typedef SSIZE_T ssize_t; | ||
+#endif | ||
|
||
struct TermKeyDriver | ||
{ | ||
@@ -41,8 +48,10 @@ struct TermKey { | ||
size_t hightide; /* Position beyond buffstart at which peekkey() should next start | ||
* normally 0, but see also termkey_interpret_csi */ | ||
|
||
+#ifndef _WIN32 | ||
struct termios restore_termios; | ||
char restore_termios_valid; | ||
+#endif | ||
|
||
TermKey_Terminfo_Getstr_Hook *ti_getstr_hook; | ||
void *ti_getstr_hook_data; | ||
diff --git a/termkey.c b/termkey.c | ||
index 2f01f3a..145b99f 100644 | ||
--- a/termkey.c | ||
+++ b/termkey.c | ||
@@ -3,14 +3,20 @@ | ||
|
||
#include <ctype.h> | ||
#include <errno.h> | ||
-#include <poll.h> | ||
-#include <unistd.h> | ||
+#ifndef _WIN32 | ||
+# include <poll.h> | ||
+# include <unistd.h> | ||
+# include <strings.h> | ||
+#endif | ||
#include <string.h> | ||
-#include <strings.h> | ||
|
||
#include <stdio.h> | ||
|
||
-#define strcaseeq(a,b) (strcasecmp(a,b) == 0) | ||
+#ifdef _MSC_VER | ||
+# define strcaseeq(a,b) (_stricmp(a,b) == 0) | ||
+#else | ||
+# define strcaseeq(a,b) (strcasecmp(a,b) == 0) | ||
+#endif | ||
|
||
void termkey_check_version(int major, int minor) | ||
{ | ||
@@ -282,7 +288,9 @@ static TermKey *termkey_alloc(void) | ||
tk->buffsize = 256; /* bytes */ | ||
tk->hightide = 0; | ||
|
||
+#ifndef _WIN32 | ||
tk->restore_termios_valid = 0; | ||
+#endif | ||
|
||
tk->ti_getstr_hook = NULL; | ||
tk->ti_getstr_hook_data = NULL; | ||
@@ -483,6 +491,7 @@ int termkey_start(TermKey *tk) | ||
if(tk->is_started) | ||
return 1; | ||
|
||
+#ifndef _WIN32 | ||
if(tk->fd != -1 && !(tk->flags & TERMKEY_FLAG_NOTERMIOS)) { | ||
struct termios termios; | ||
if(tcgetattr(tk->fd, &termios) == 0) { | ||
@@ -517,6 +526,7 @@ int termkey_start(TermKey *tk) | ||
tcsetattr(tk->fd, TCSANOW, &termios); | ||
} | ||
} | ||
+#endif | ||
|
||
struct TermKeyDriverNode *p; | ||
for(p = tk->drivers; p; p = p->next) | ||
@@ -542,8 +552,10 @@ int termkey_stop(TermKey *tk) | ||
if(p->driver->stop_driver) | ||
(*p->driver->stop_driver)(tk, p->info); | ||
|
||
+#ifndef _WIN32 | ||
if(tk->restore_termios_valid) | ||
tcsetattr(tk->fd, TCSANOW, &tk->restore_termios); | ||
+#endif | ||
|
||
tk->is_started = 0; | ||
|
||
@@ -1046,6 +1058,7 @@ TermKeyResult termkey_getkey_force(TermKey *tk, TermKeyKey *key) | ||
return ret; | ||
} | ||
|
||
+#ifndef _WIN32 | ||
TermKeyResult termkey_waitkey(TermKey *tk, TermKeyKey *key) | ||
{ | ||
if(tk->fd == -1) { | ||
@@ -1105,6 +1118,7 @@ retry: | ||
|
||
/* UNREACHABLE */ | ||
} | ||
+#endif | ||
|
||
TermKeyResult termkey_advisereadable(TermKey *tk) | ||
{ | ||
-- | ||
2.16.1.windows.4 | ||
|
24 changes: 24 additions & 0 deletions
24
third-party/patches/luv-Add-missing-definitions-for-MinGW.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
diff --git a/src/dns.c b/src/dns.c | ||
index 8634157..5f36625 100644 | ||
--- a/src/dns.c | ||
+++ b/src/dns.c | ||
@@ -20,6 +20,19 @@ | ||
#include <sys/types.h> | ||
#include <sys/socket.h> | ||
#include <netdb.h> | ||
+#elif __MINGW32__ | ||
+# ifndef AI_NUMERICSERV | ||
+# define AI_NUMERICSERV 0x0008 | ||
+# endif | ||
+# ifndef AI_ALL | ||
+# define AI_ALL 0x00000100 | ||
+# endif | ||
+# ifndef AI_ADDRCONFIG | ||
+# define AI_ADDRCONFIG 0x00000400 | ||
+# endif | ||
+# ifndef AI_V4MAPPED | ||
+# define AI_V4MAPPED 0x00000800 | ||
+# endif | ||
#endif | ||
|
||
static void luv_pushaddrinfo(lua_State* L, struct addrinfo* res) { |