To: vim_dev@googlegroups.com Subject: Patch 8.2.3208 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3208 Problem: Dynamic library load error does not mention why it failed. Solution: Add the error message. (Martin Tournoij, closes #8621) Files: src/globals.h, src/if_cscope.c, src/if_lua.c, src/if_mzsch.c, src/if_perl.xs, src/if_python.c, src/if_python3.c, src/if_ruby.c, src/if_tcl.c, src/mbyte.c, src/os_win32.c, src/proto/os_win32.pro, src/terminal.c *** ../vim-8.2.3207/src/globals.h 2021-07-23 20:37:52.018322443 +0200 --- src/globals.h 2021-07-24 13:52:48.261919267 +0200 *************** *** 1632,1638 **** || defined(DYNAMIC_MZSCHEME) \ || defined(DYNAMIC_LUA) \ || defined(FEAT_TERMINAL) ! EXTERN char e_loadlib[] INIT(= N_("E370: Could not load library %s")); EXTERN char e_loadfunc[] INIT(= N_("E448: Could not load library function %s")); #endif EXTERN char e_nobang[] INIT(= N_("E477: No ! allowed")); --- 1632,1638 ---- || defined(DYNAMIC_MZSCHEME) \ || defined(DYNAMIC_LUA) \ || defined(FEAT_TERMINAL) ! EXTERN char e_loadlib[] INIT(= N_("E370: Could not load library %s: %s")); EXTERN char e_loadfunc[] INIT(= N_("E448: Could not load library function %s")); #endif EXTERN char e_nobang[] INIT(= N_("E477: No ! allowed")); *** ../vim-8.2.3207/src/if_cscope.c 2021-02-03 19:35:09.610557545 +0100 --- src/if_cscope.c 2021-07-24 13:52:48.261919267 +0200 *************** *** 1329,1352 **** #endif } - #ifndef UNIX - static char * - GetWin32Error(void) - { - char *msg = NULL; - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, - NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); - if (msg != NULL) - { - // remove trailing \r\n - char *pcrlf = strstr(msg, "\r\n"); - if (pcrlf != NULL) - *pcrlf = '\0'; - } - return msg; - } - #endif - /* * Insert a new cscope database filename into the filelist. */ --- 1329,1334 ---- *** ../vim-8.2.3207/src/if_lua.c 2021-04-07 20:11:07.987846226 +0200 --- src/if_lua.c 2021-07-24 13:52:48.261919267 +0200 *************** *** 105,114 **** --- 105,116 ---- # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) # define symbol_from_dll dlsym # define close_dll dlclose + # define load_dll_error dlerror #else # define load_dll vimLoadLib # define symbol_from_dll GetProcAddress # define close_dll FreeLibrary + # define load_dll_error GetWin32Error #endif // lauxlib *************** *** 446,452 **** if (!hinstLua) { if (verbose) ! semsg(_(e_loadlib), libname); return FAIL; } for (reg = luaV_dll; reg->func; reg++) --- 448,454 ---- if (!hinstLua) { if (verbose) ! semsg(_(e_loadlib), libname, load_dll_error()); return FAIL; } for (reg = luaV_dll; reg->func; reg++) *** ../vim-8.2.3207/src/if_mzsch.c 2021-06-02 13:28:11.431120460 +0200 --- src/if_mzsch.c 2021-07-24 13:52:48.261919267 +0200 *************** *** 668,681 **** if (!hMzGC) { if (verbose) ! semsg(_(e_loadlib), gc_dll); return FAIL; } if (!hMzSch) { if (verbose) ! semsg(_(e_loadlib), sch_dll); return FAIL; } --- 668,681 ---- if (!hMzGC) { if (verbose) ! semsg(_(e_loadlib), gc_dll, GetWin32Error()); return FAIL; } if (!hMzSch) { if (verbose) ! semsg(_(e_loadlib), sch_dll, GetWin32Error()); return FAIL; } *** ../vim-8.2.3207/src/if_perl.xs 2021-05-27 18:05:10.124200971 +0200 --- src/if_perl.xs 2021-07-24 13:52:48.261919267 +0200 *************** *** 175,185 **** --- 175,187 ---- # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) # define symbol_from_dll dlsym # define close_dll dlclose + # define load_dll_error dlerror # else # define PERL_PROC FARPROC # define load_dll vimLoadLib # define symbol_from_dll GetProcAddress # define close_dll FreeLibrary + # define load_dll_error GetWin32Error # endif /* * Wrapper defines *** ../vim-8.2.3207/src/if_python.c 2020-12-21 16:02:58.486392542 +0100 --- src/if_python.c 2021-07-24 13:52:48.261919267 +0200 *************** *** 141,150 **** --- 141,152 ---- # endif # define close_dll dlclose # define symbol_from_dll dlsym + # define load_dll_error dlerror # else # define load_dll vimLoadLib # define close_dll FreeLibrary # define symbol_from_dll GetProcAddress + # define load_dll_error GetWin32Error # endif // This makes if_python.c compile without warnings against Python 2.5 *************** *** 688,694 **** if (!hinstPython) { if (verbose) ! semsg(_(e_loadlib), libname); return FAIL; } --- 690,696 ---- if (!hinstPython) { if (verbose) ! semsg(_(e_loadlib), libname, load_dll_error()); return FAIL; } *** ../vim-8.2.3207/src/if_python3.c 2021-06-14 15:08:26.331250889 +0200 --- src/if_python3.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 125,134 **** --- 125,136 ---- # endif # define close_dll dlclose # define symbol_from_dll dlsym + # define load_dll_error dlerror # else # define load_dll vimLoadLib # define close_dll FreeLibrary # define symbol_from_dll GetProcAddress + # define load_dll_error GetWin32Error # endif /* * Wrapper defines *************** *** 795,801 **** if (!hinstPy3) { if (verbose) ! semsg(_(e_loadlib), libname); return FAIL; } --- 797,803 ---- if (!hinstPy3) { if (verbose) ! semsg(_(e_loadlib), libname, load_dll_error()); return FAIL; } *** ../vim-8.2.3207/src/if_ruby.c 2021-02-01 19:31:43.969603658 +0100 --- src/if_ruby.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 184,194 **** --- 184,196 ---- # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) # define symbol_from_dll dlsym # define close_dll dlclose + # define load_dll_error dlerror # else # define RUBY_PROC FARPROC # define load_dll vimLoadLib # define symbol_from_dll GetProcAddress # define close_dll FreeLibrary + # define load_dll_error GetWin32Error # endif #endif *************** *** 806,812 **** if (!hinstRuby) { if (verbose) ! semsg(_(e_loadlib), libname); return FAIL; } --- 808,814 ---- if (!hinstRuby) { if (verbose) ! semsg(_(e_loadlib), libname, load_dll_error()); return FAIL; } *** ../vim-8.2.3207/src/if_tcl.c 2021-06-15 19:09:20.778539956 +0200 --- src/if_tcl.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 167,177 **** --- 167,179 ---- # define load_dll(n) dlopen((n), RTLD_LAZY|RTLD_GLOBAL) # define symbol_from_dll dlsym # define close_dll dlclose + # define load_dll_error dlerror # else # define TCL_PROC FARPROC # define load_dll vimLoadLib # define symbol_from_dll GetProcAddress # define close_dll FreeLibrary + # define load_dll_error GetWin32Error # endif /* *************** *** 213,219 **** if (!(hTclLib = load_dll(libname))) { if (verbose) ! semsg(_(e_loadlib), libname); return FAIL; } for (i = 0; tcl_funcname_table[i].ptr; ++i) --- 215,221 ---- if (!(hTclLib = load_dll(libname))) { if (verbose) ! semsg(_(e_loadlib), libname, load_dll_error()); return FAIL; } for (i = 0; tcl_funcname_table[i].ptr; ++i) *** ../vim-8.2.3207/src/mbyte.c 2021-07-10 21:28:55.327050110 +0200 --- src/mbyte.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 4902,4908 **** { verbose_enter(); semsg(_(e_loadlib), ! hIconvDLL == 0 ? DYNAMIC_ICONV_DLL : DYNAMIC_MSVCRT_DLL); verbose_leave(); } iconv_end(); --- 4902,4909 ---- { verbose_enter(); semsg(_(e_loadlib), ! hIconvDLL == 0 ? DYNAMIC_ICONV_DLL : DYNAMIC_MSVCRT_DLL, ! GetWin32Error()); verbose_leave(); } iconv_end(); *** ../vim-8.2.3207/src/os_win32.c 2021-06-30 20:54:30.696546341 +0200 --- src/os_win32.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 716,722 **** if (p_verbose > 0) { verbose_enter(); ! semsg(_(e_loadlib), GETTEXT_DLL); verbose_leave(); } return 0; --- 716,722 ---- if (p_verbose > 0) { verbose_enter(); ! semsg(_(e_loadlib), GETTEXT_DLL, GetWin32Error()); verbose_leave(); } return 0; *************** *** 8353,8355 **** --- 8353,8371 ---- } } #endif + + char * + GetWin32Error(void) + { + char *msg = NULL; + FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, + NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL); + if (msg != NULL) + { + // remove trailing \r\n + char *pcrlf = strstr(msg, "\r\n"); + if (pcrlf != NULL) + *pcrlf = '\0'; + } + return msg; + } *** ../vim-8.2.3207/src/proto/os_win32.pro 2020-08-23 14:28:24.111838486 +0200 --- src/proto/os_win32.pro 2021-07-24 13:52:48.265919258 +0200 *************** *** 83,86 **** --- 83,87 ---- int is_conpty_stable(void); int get_conpty_fix_type(void); void resize_console_buf(void); + char * GetWin32Error(void); /* vim: set ft=c : */ *** ../vim-8.2.3207/src/terminal.c 2021-07-23 20:37:52.022322433 +0200 --- src/terminal.c 2021-07-24 13:52:48.265919258 +0200 *************** *** 6862,6869 **** if (!hWinPtyDLL) { if (verbose) ! semsg(_(e_loadlib), *p_winptydll != NUL ? p_winptydll ! : (char_u *)WINPTY_DLL); return FAIL; } for (i = 0; winpty_entry[i].name != NULL --- 6862,6870 ---- if (!hWinPtyDLL) { if (verbose) ! semsg(_(e_loadlib), ! (*p_winptydll != NUL ? p_winptydll : (char_u *)WINPTY_DLL), ! GetWin32Error()); return FAIL; } for (i = 0; winpty_entry[i].name != NULL *** ../vim-8.2.3207/src/version.c 2021-07-24 13:18:43.861887612 +0200 --- src/version.c 2021-07-24 13:55:24.673569502 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3208, /**/ -- hundred-and-one symptoms of being an internet addict: 222. You send more than 20 personal e-mails a day. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///