To: vim_dev@googlegroups.com Subject: Patch 8.0.0952 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.0952 Problem: MS-Windows: has('terminal') does not check existence of dll file. Solution: Check if the winpty dll file can be loaded. (Ken Takata) Files: src/evalfunc.c, src/proto/terminal.pro, src/terminal.c *** ../vim-8.0.0951/src/evalfunc.c 2017-08-16 22:45:57.677684067 +0200 --- src/evalfunc.c 2017-08-17 14:27:11.742775523 +0200 *************** *** 5926,5932 **** #ifdef FEAT_TERMGUICOLORS "termguicolors", #endif ! #ifdef FEAT_TERMINAL "terminal", #endif #ifdef TERMINFO --- 5926,5932 ---- #ifdef FEAT_TERMGUICOLORS "termguicolors", #endif ! #if defined(FEAT_TERMINAL) && !defined(WIN3264) "terminal", #endif #ifdef TERMINFO *************** *** 6134,6139 **** --- 6134,6143 ---- else if (STRICMP(name, "netbeans_enabled") == 0) n = netbeans_active(); #endif + #if defined(FEAT_TERMINAL) && defined(WIN3264) + else if (STRICMP(name, "terminal") == 0) + n = terminal_enabled(); + #endif } rettv->vval.v_number = n; *** ../vim-8.0.0951/src/proto/terminal.pro 2017-08-12 22:55:54.217280907 +0200 --- src/proto/terminal.pro 2017-08-17 14:34:00.944223322 +0200 *************** *** 34,37 **** --- 34,38 ---- void f_term_sendkeys(typval_T *argvars, typval_T *rettv); void f_term_start(typval_T *argvars, typval_T *rettv); void f_term_wait(typval_T *argvars, typval_T *rettv); + int terminal_enabled(void); /* vim: set ft=c : */ *** ../vim-8.0.0951/src/terminal.c 2017-08-16 23:14:03.539122761 +0200 --- src/terminal.c 2017-08-17 14:35:42.143582665 +0200 *************** *** 2709,2720 **** } } ! # ifdef WIN3264 /************************************** * 2. MS-Windows implementation. */ #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull --- 2709,2722 ---- } } ! # if defined(WIN3264) || defined(PROTO) /************************************** * 2. MS-Windows implementation. */ + # ifndef PROTO + #define WINPTY_SPAWN_FLAG_AUTO_SHUTDOWN 1ul #define WINPTY_SPAWN_FLAG_EXIT_AFTER_SHUTDOWN 2ull *************** *** 2737,2745 **** #define WINPTY_DLL "winpty.dll" static HINSTANCE hWinPtyDLL = NULL; ! int ! dyn_winpty_init(void) { int i; static struct --- 2739,2748 ---- #define WINPTY_DLL "winpty.dll" static HINSTANCE hWinPtyDLL = NULL; + # endif ! static int ! dyn_winpty_init(int verbose) { int i; static struct *************** *** 2768,2774 **** /* No need to initialize twice. */ if (hWinPtyDLL) ! return 1; /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just * winpty.dll. */ if (*p_winptydll != NUL) --- 2771,2777 ---- /* No need to initialize twice. */ if (hWinPtyDLL) ! return OK; /* Load winpty.dll, prefer using the 'winptydll' option, fall back to just * winpty.dll. */ if (*p_winptydll != NUL) *************** *** 2777,2784 **** hWinPtyDLL = vimLoadLib(WINPTY_DLL); if (!hWinPtyDLL) { ! EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll : WINPTY_DLL); ! return 0; } for (i = 0; winpty_entry[i].name != NULL && winpty_entry[i].ptr != NULL; ++i) --- 2780,2789 ---- hWinPtyDLL = vimLoadLib(WINPTY_DLL); if (!hWinPtyDLL) { ! if (verbose) ! EMSG2(_(e_loadlib), *p_winptydll != NUL ? p_winptydll ! : (char_u *)WINPTY_DLL); ! return FAIL; } for (i = 0; winpty_entry[i].name != NULL && winpty_entry[i].ptr != NULL; ++i) *************** *** 2786,2797 **** if ((*winpty_entry[i].ptr = (FARPROC)GetProcAddress(hWinPtyDLL, winpty_entry[i].name)) == NULL) { ! EMSG2(_(e_loadfunc), winpty_entry[i].name); ! return 0; } } ! return 1; } /* --- 2791,2803 ---- if ((*winpty_entry[i].ptr = (FARPROC)GetProcAddress(hWinPtyDLL, winpty_entry[i].name)) == NULL) { ! if (verbose) ! EMSG2(_(e_loadfunc), winpty_entry[i].name); ! return FAIL; } } ! return OK; } /* *************** *** 2813,2819 **** garray_T ga; char_u *cmd; ! if (!dyn_winpty_init()) return FAIL; if (argvar->v_type == VAR_STRING) --- 2819,2825 ---- garray_T ga; char_u *cmd; ! if (dyn_winpty_init(TRUE) == FAIL) return FAIL; if (argvar->v_type == VAR_STRING) *************** *** 2977,2982 **** --- 2983,2995 ---- winpty_set_size(term->tl_winpty, cols, rows, NULL); } + int + terminal_enabled(void) + { + return dyn_winpty_init(FALSE) == OK; + } + + # else /************************************** *** ../vim-8.0.0951/src/version.c 2017-08-17 11:33:37.704130217 +0200 --- src/version.c 2017-08-17 14:29:51.873776861 +0200 *************** *** 771,772 **** --- 771,774 ---- { /* Add new patch number below this line */ + /**/ + 952, /**/ -- CART DRIVER: Bring out your dead! LARGE MAN: Here's one! CART DRIVER: Ninepence. BODY: I'm not dead! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///