changeset 2295:b9bc9c5df131 vim73

Support wide file names in gvimext. (Szabolcs Horvat)
author Bram Moolenaar <bram@vim.org>
date Sat, 10 Jul 2010 19:22:44 +0200
parents 2209060c340d
children eb7be7b075a6
files runtime/doc/todo.txt src/GvimExt/gvimext.cpp
diffstat 2 files changed, 39 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -1089,11 +1089,10 @@ 2010 Jun 30)
 
 
 Vim 7.3:
-- in August remove UF_VERSION_CRYPT_PREV and UF_VERSION_PREV.
+- soon: remove UF_VERSION_CRYPT_PREV and UF_VERSION_PREV.
 - Conceal feature: no update when moving to another window. (Dominique Pelle,
   2010 Jul 5)  Vince will look into it.
 Patches to include:
-- Patch for Lisp support with ECL (Mikael Jansson, 2008 Oct 25)
 - Gvimext patch to support wide file names. (Szabolcs Horvat 2008 Sep 10)
 - Patch to support netbeans for Mac. (Kazuki Sakamoto, 2009 Jun 25)
 - Patch to support clipboard for Mac terminal. (Jjgod Jiang, 2009 Aug 1)
--- a/src/GvimExt/gvimext.cpp
+++ b/src/GvimExt/gvimext.cpp
@@ -85,6 +85,17 @@ getGvimName(char *name, int runtime)
     }
 }
 
+    static void
+getGvimNameW(wchar_t *nameW)
+{
+    char *name;
+
+    name = (char *)malloc(BUFSIZE);
+    getGvimName(name, 0);
+    mbstowcs(nameW, name, BUFSIZE);
+    free(name);
+}
+
 //
 // Get the Vim runtime directory into buf[BUFSIZE].
 // The result is empty when it failed.
@@ -848,34 +859,34 @@ STDMETHODIMP CShellExt::InvokeGvim(HWND 
 				   LPCSTR  /* pszParam */,
 				   int  /* iShowCmd */)
 {
-    char m_szFileUserClickedOn[BUFSIZE];
-    char cmdStr[BUFSIZE];
+    wchar_t m_szFileUserClickedOn[BUFSIZE];
+    wchar_t cmdStrW[BUFSIZE];
     UINT i;
 
     for (i = 0; i < cbFiles; i++)
     {
-	DragQueryFile((HDROP)medium.hGlobal,
+	DragQueryFileW((HDROP)medium.hGlobal,
 		i,
 		m_szFileUserClickedOn,
 		sizeof(m_szFileUserClickedOn));
 
-	getGvimName(cmdStr, 0);
-	strcat(cmdStr, " \"");
+	getGvimNameW(cmdStrW);
+	wcscat(cmdStrW, L" \"");
 
-	if ((strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 2) < BUFSIZE)
+	if ((wcslen(cmdStrW) + wcslen(m_szFileUserClickedOn) + 2) < BUFSIZE)
 	{
-	    strcat(cmdStr, m_szFileUserClickedOn);
-	    strcat(cmdStr, "\"");
+	    wcscat(cmdStrW, m_szFileUserClickedOn);
+	    wcscat(cmdStrW, L"\"");
 
-	    STARTUPINFO si;
+	    STARTUPINFOW si;
 	    PROCESS_INFORMATION pi;
 
 	    ZeroMemory(&si, sizeof(si));
 	    si.cb = sizeof(si);
 
 	    // Start the child process.
-	    if (!CreateProcess(NULL,	// No module name (use command line).
-			cmdStr,		// Command line.
+	    if (!CreateProcessW(NULL,	// No module name (use command line).
+			cmdStrW,	// Command line.
 			NULL,		// Process handle not inheritable.
 			NULL,		// Thread handle not inheritable.
 			FALSE,		// Set handle inheritance to FALSE.
@@ -919,44 +930,45 @@ STDMETHODIMP CShellExt::InvokeSingleGvim
 				   int  /* iShowCmd */,
 				   int useDiff)
 {
-    char	m_szFileUserClickedOn[BUFSIZE];
-    char	*cmdStr;
+    wchar_t	m_szFileUserClickedOn[BUFSIZE];
+    wchar_t	*cmdStrW;
     size_t	cmdlen;
     size_t	len;
     UINT i;
 
     cmdlen = BUFSIZE;
-    cmdStr = (char *)malloc(cmdlen);
-    getGvimName(cmdStr, 0);
+    cmdStrW  = (wchar_t *) malloc(cmdlen * sizeof(wchar_t));
+    getGvimNameW(cmdStrW);
+
     if (useDiff)
-	strcat(cmdStr, " -d");
+	wcscat(cmdStrW, L" -d");
     for (i = 0; i < cbFiles; i++)
     {
-	DragQueryFile((HDROP)medium.hGlobal,
+	DragQueryFileW((HDROP)medium.hGlobal,
 		i,
 		m_szFileUserClickedOn,
 		sizeof(m_szFileUserClickedOn));
 
-	len = strlen(cmdStr) + strlen(m_szFileUserClickedOn) + 4;
+	len = wcslen(cmdStrW) + wcslen(m_szFileUserClickedOn) + 4;
 	if (len > cmdlen)
 	{
 	    cmdlen = len + BUFSIZE;
-	    cmdStr = (char *)realloc(cmdStr, cmdlen);
+	    cmdStrW = (wchar_t *)realloc(cmdStrW, cmdlen * sizeof(wchar_t));
 	}
-	strcat(cmdStr, " \"");
-	strcat(cmdStr, m_szFileUserClickedOn);
-	strcat(cmdStr, "\"");
+	wcscat(cmdStrW, L" \"");
+	wcscat(cmdStrW, m_szFileUserClickedOn);
+	wcscat(cmdStrW, L"\"");
     }
 
-    STARTUPINFO si;
+    STARTUPINFOW si;
     PROCESS_INFORMATION pi;
 
     ZeroMemory(&si, sizeof(si));
     si.cb = sizeof(si);
 
     // Start the child process.
-    if (!CreateProcess(NULL,	// No module name (use command line).
-		cmdStr,		// Command line.
+    if (!CreateProcessW(NULL,	// No module name (use command line).
+		cmdStrW,	// Command line.
 		NULL,		// Process handle not inheritable.
 		NULL,		// Thread handle not inheritable.
 		FALSE,		// Set handle inheritance to FALSE.
@@ -979,7 +991,7 @@ STDMETHODIMP CShellExt::InvokeSingleGvim
 	CloseHandle(pi.hThread);
     }
 
-    free(cmdStr);
+    free(cmdStrW);
 
     return NOERROR;
 }