diff options
author | erw7 <erw7.github@gmail.com> | 2019-11-16 12:59:07 +0900 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2020-01-17 11:36:28 +0100 |
commit | 59ae38a9196d596e2fe511eeb216e314bfc3dac7 (patch) | |
tree | 4961298db8770f0db816f4d72f5fd31d416b3181 /src/nvim/os | |
parent | b25e42f7989aa0a071e3132ce992ab9a6251594e (diff) | |
download | rneovim-59ae38a9196d596e2fe511eeb216e314bfc3dac7.tar.gz rneovim-59ae38a9196d596e2fe511eeb216e314bfc3dac7.tar.bz2 rneovim-59ae38a9196d596e2fe511eeb216e314bfc3dac7.zip |
Change to use TriState instead of bool
Co-Authored-By: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'src/nvim/os')
-rw-r--r-- | src/nvim/os/os_win_conpty.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/nvim/os/os_win_conpty.c b/src/nvim/os/os_win_conpty.c index a73b1b65a0..3d5ba83523 100644 --- a/src/nvim/os/os_win_conpty.c +++ b/src/nvim/os/os_win_conpty.c @@ -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, |