]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.3208: dynamic library load error does not mention why it failed v8.2.3208
authorMartin Tournoij <martin@arp242.net>
Sat, 24 Jul 2021 11:57:29 +0000 (13:57 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 24 Jul 2021 11:57:29 +0000 (13:57 +0200)
Problem:    Dynamic library load error does not mention why it failed.
Solution:   Add the error message. (Martin Tournoij, closes #8621)

14 files changed:
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
src/version.c

index 4737adc83df52bf9f1c61c0d5882e40d9da4c355..1a2451225871fe3ebbe63b75be4475088d1de327 100644 (file)
@@ -1632,7 +1632,7 @@ EXTERN char e_fsync[]             INIT(= N_("E667: Fsync failed"));
        || defined(DYNAMIC_MZSCHEME) \
        || defined(DYNAMIC_LUA) \
        || defined(FEAT_TERMINAL)
-EXTERN char e_loadlib[]        INIT(= N_("E370: Could not load library %s"));
+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"));
index f52316faec245459c538bb67d80dd4ddfb03ed4d..815db55c192baa49fabd223520f972291fff768f 100644 (file)
@@ -1329,24 +1329,6 @@ clear_csinfo(int i)
 #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.
  */
index c19244fae57958b326d5d970e35ab937c13fe49c..82dffb0bafddf6fb68107b6d31bab36b1d5cd6f2 100644 (file)
@@ -105,10 +105,12 @@ static void luaV_call_lua_func_free(void *state);
 # 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,7 +448,7 @@ lua_link_init(char *libname, int verbose)
     if (!hinstLua)
     {
        if (verbose)
-           semsg(_(e_loadlib), libname);
+           semsg(_(e_loadlib), libname, load_dll_error());
        return FAIL;
     }
     for (reg = luaV_dll; reg->func; reg++)
index 0c1c765db53c4eb74f1ce22d0504132d04278ad1..c8be940bc90bdadad8b70cf7300bb9d5d29a57e8 100644 (file)
@@ -668,14 +668,14 @@ mzscheme_runtime_link_init(char *sch_dll, char *gc_dll, int verbose)
     if (!hMzGC)
     {
        if (verbose)
-           semsg(_(e_loadlib), gc_dll);
+           semsg(_(e_loadlib), gc_dll, GetWin32Error());
        return FAIL;
     }
 
     if (!hMzSch)
     {
        if (verbose)
-           semsg(_(e_loadlib), sch_dll);
+           semsg(_(e_loadlib), sch_dll, GetWin32Error());
        return FAIL;
     }
 
index 3b0fead5df2ccc0d656dbe16b89b8ee9d7243bfe..3d683bd9c86becef5434a61cc2d1c2321a1cd482 100644 (file)
@@ -175,11 +175,13 @@ typedef int perl_key;
 #  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
index 7f90ede156ab234dc66b1bbbc2a5c174316bef19..a27098245ab30c038e9887ea1211d90b91b5467b 100644 (file)
@@ -141,10 +141,12 @@ struct PyMethodDef { Py_ssize_t a; };
 #  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,7 +690,7 @@ python_runtime_link_init(char *libname, int verbose)
     if (!hinstPython)
     {
        if (verbose)
-           semsg(_(e_loadlib), libname);
+           semsg(_(e_loadlib), libname, load_dll_error());
        return FAIL;
     }
 
index c7db9d7a2a8b9160e917a8c481939d17ced973ff..4944ab813c52061ddd845c62517d9fb0faf7a6a6 100644 (file)
@@ -125,10 +125,12 @@ typedef PySliceObject PySliceObject_T;
 #  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,7 +797,7 @@ py3_runtime_link_init(char *libname, int verbose)
     if (!hinstPy3)
     {
        if (verbose)
-           semsg(_(e_loadlib), libname);
+           semsg(_(e_loadlib), libname, load_dll_error());
        return FAIL;
     }
 
index 1d49d671e40347177266b64bdb4bd7af9556941a..5098468e6aef98b3712a820327372f4b98e96feb 100644 (file)
 #  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,7 +808,7 @@ ruby_runtime_link_init(char *libname, int verbose)
     if (!hinstRuby)
     {
        if (verbose)
-           semsg(_(e_loadlib), libname);
+           semsg(_(e_loadlib), libname, load_dll_error());
        return FAIL;
     }
 
index c3b9c5bbee2347c5f5b0caa9df230ed9b37bf10f..f3f4b0798a46db85877017640391230c687925c8 100644 (file)
@@ -167,11 +167,13 @@ typedef int HANDLE;
 #  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,7 +215,7 @@ tcl_runtime_link_init(char *libname, int verbose)
     if (!(hTclLib = load_dll(libname)))
     {
        if (verbose)
-           semsg(_(e_loadlib), libname);
+           semsg(_(e_loadlib), libname, load_dll_error());
        return FAIL;
     }
     for (i = 0; tcl_funcname_table[i].ptr; ++i)
index 6fb046d342248f0a12fb375a78196c41480f25c2..3d5ad7636127b16e662a2d600698a522aeedf322 100644 (file)
@@ -4902,7 +4902,8 @@ iconv_enabled(int verbose)
        {
            verbose_enter();
            semsg(_(e_loadlib),
-                   hIconvDLL == 0 ? DYNAMIC_ICONV_DLL : DYNAMIC_MSVCRT_DLL);
+                   hIconvDLL == 0 ? DYNAMIC_ICONV_DLL : DYNAMIC_MSVCRT_DLL,
+                   GetWin32Error());
            verbose_leave();
        }
        iconv_end();
index eff2269f8c4de86e85398250d0b47dabe5f0978f..91bd18a8b3b5d0023ec824ffa9edc0fbf6c4af0d 100644 (file)
@@ -716,7 +716,7 @@ dyn_libintl_init(void)
        if (p_verbose > 0)
        {
            verbose_enter();
-           semsg(_(e_loadlib), GETTEXT_DLL);
+           semsg(_(e_loadlib), GETTEXT_DLL, GetWin32Error());
            verbose_leave();
        }
        return 0;
@@ -8353,3 +8353,19 @@ resize_console_buf(void)
     }
 }
 #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;
+}
index 18c81273e1e4618c6fb1b98495fe17dbcf5d50a1..4d360d70e2edf148f7e1a6eef9cccfc6fb64ca8b 100644 (file)
@@ -83,4 +83,5 @@ int get_conpty_type(void);
 int is_conpty_stable(void);
 int get_conpty_fix_type(void);
 void resize_console_buf(void);
+char * GetWin32Error(void);
 /* vim: set ft=c : */
index 1f64c8bd6361c3a7a59ffca25731b5fd87d55d56..98b46004e7fed95d99f33f1a32f0b0adf7f6f9e7 100644 (file)
@@ -6862,8 +6862,9 @@ dyn_winpty_init(int verbose)
     if (!hWinPtyDLL)
     {
        if (verbose)
-           semsg(_(e_loadlib), *p_winptydll != NUL ? p_winptydll
-                                                      : (char_u *)WINPTY_DLL);
+           semsg(_(e_loadlib),
+                   (*p_winptydll != NUL ? p_winptydll : (char_u *)WINPTY_DLL),
+                   GetWin32Error());
        return FAIL;
     }
     for (i = 0; winpty_entry[i].name != NULL
index 387a6e66ca00ed16713206ba5c39f1b283b037ad..64622c31159392d8b109b3d8fe0b0f8200feeb1c 100644 (file)
@@ -755,6 +755,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3208,
 /**/
     3207,
 /**/