[Groonga-commit] groonga/groonga at 2fd9ae2 [master] windows: remove extended path prefix \\?\ (#970)

Back to archive index
Kentaro Hayashi null+****@clear*****
Wed May 29 15:21:45 JST 2019


Kentaro Hayashi	2019-05-29 15:21:45 +0900 (Wed, 29 May 2019)

  Revision: 2fd9ae2098a1947f717f24c6cc9cbc1a1681c921
  https://github.com/groonga/groonga/commit/2fd9ae2098a1947f717f24c6cc9cbc1a1681c921

  Message:
    windows: remove extended path prefix \\?\ (#970)
    
    * windows: remove extended path prefix "\\?\"
    
    There is a case that GetModuleFileNameW returns path which contains
    extended path prefix \\?\ as module filename. It causes a bug that
    plugin can't be found correctly because of this kind of extended path
    prefix.
    
    TODO: Support long path correctly on Windows. (Drop MAX_PATH limitation)
    
    GitHub:#958
    
    Reported by @yagisumi Thanks!!!
    
    * plugin: show filename which is failed to load
    
    Before:
    
      system error[126]: The specified module could not be found.: LoadLibrary
    
    After:
    
      system error[126]: The specified module could not be found.: LoadLibrary: <XXXX>

  Modified files:
    lib/grn_windows.h
    lib/plugin.c
    lib/windows.c

  Modified: lib/grn_windows.h (+1 -0)
===================================================================
--- lib/grn_windows.h    2019-05-29 11:58:48 +0900 (dd80aa54b)
+++ lib/grn_windows.h    2019-05-29 15:21:45 +0900 (7939dc325)
@@ -19,6 +19,7 @@
 #pragma once
 
 #include "grn.h"
+#include "wchar.h"
 
 #ifdef __cplusplus
 extern "C" {

  Modified: lib/plugin.c (+1 -1)
===================================================================
--- lib/plugin.c    2019-05-29 11:58:48 +0900 (edbffb3b9)
+++ lib/plugin.c    2019-05-29 15:21:45 +0900 (01f116778)
@@ -440,7 +440,7 @@ grn_plugin_open(grn_ctx *ctx, const char *filename)
   } else {
     const char *label;
     label = grn_dl_open_error_label();
-    SERR("%s", label);
+    SERR("%s: <%.*s>", label, filename_size, filename);
   }
 
 exit:

  Modified: lib/windows.c (+6 -0)
===================================================================
--- lib/windows.c    2019-05-29 11:58:48 +0900 (fd2940d12)
+++ lib/windows.c    2019-05-29 15:21:45 +0900 (141c0a064)
@@ -43,6 +43,12 @@ grn_windows_base_dir(void)
 
         absolute_dll_filename[absolute_dll_filename_size] = L'\0';
 
+        if (wcsncmp(absolute_dll_filename, L"\\\\?\\", 4) == 0) {
+          wmemmove(absolute_dll_filename, &absolute_dll_filename[4], absolute_dll_filename_size - 4);
+          absolute_dll_filename[absolute_dll_filename_size - 4] = L'\0';
+          absolute_dll_filename_size -= 4;
+        }
+
         for (i = 0; i < absolute_dll_filename_size; i++) {
           if (absolute_dll_filename[i] == L'\\') {
             absolute_dll_filename[i] = L'/';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190529/bdd83c9d/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index