Change to use TriState instead of bool

Co-Authored-By: Justin M. Keyes <justinkz@gmail.com>
This commit is contained in:
erw7 2019-11-16 12:59:07 +09:00 committed by Björn Linse
parent b25e42f798
commit 59ae38a919
2 changed files with 10 additions and 13 deletions

View File

@ -46,9 +46,6 @@
#include "nvim/option.h"
#include "nvim/os_unix.h"
#include "nvim/os/os_defs.h"
#ifdef WIN32
# include "nvim/os/os_win_conpty.h"
#endif
#include "nvim/path.h"
#include "nvim/profile.h"
#include "nvim/popupmnu.h"
@ -229,9 +226,6 @@ void early_init(void)
init_signs();
ui_comp_syn_init();
#ifdef WIN32
os_dyn_conpty_init();
#endif
}
#ifdef MAKE_LIB

View File

@ -14,23 +14,26 @@
# define PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE 0x00020016
#endif
static bool conpty_working = false;
HRESULT (WINAPI *pCreatePseudoConsole)(COORD, HANDLE, HANDLE, DWORD, HPCON *);
HRESULT (WINAPI *pResizePseudoConsole)(HPCON, COORD);
void (WINAPI *pClosePseudoConsole)(HPCON);
bool os_has_conpty_working(void)
{
return conpty_working;
static TriState has_conpty = kNone;
if (has_conpty == kNone) {
has_conpty = os_dyn_conpty_init();
}
return has_conpty == kTrue;
}
void os_dyn_conpty_init(void)
TriState os_dyn_conpty_init(void)
{
uv_lib_t kernel;
if (uv_dlopen("kernel32.dll", &kernel)) {
uv_dlclose(&kernel);
return;
return kFalse;
}
static struct {
char *name;
@ -45,10 +48,10 @@ void os_dyn_conpty_init(void)
conpty_entry[i].name != NULL && conpty_entry[i].ptr != NULL; i++) {
if (uv_dlsym(&kernel, conpty_entry[i].name, (void **)conpty_entry[i].ptr)) {
uv_dlclose(&kernel);
return;
return kFalse;
}
}
conpty_working = true;
return kTrue;
}
conpty_t *os_conpty_init(char **in_name, char **out_name,