jkunstle / rpms / vim

Forked from rpms/vim 3 years ago
Clone

Blame SOURCES/7.4.012

8b9a1c
To: vim_dev@googlegroups.com
8b9a1c
Subject: Patch 7.4.012
8b9a1c
Fcc: outbox
8b9a1c
From: Bram Moolenaar <Bram@moolenaar.net>
8b9a1c
Mime-Version: 1.0
8b9a1c
Content-Type: text/plain; charset=UTF-8
8b9a1c
Content-Transfer-Encoding: 8bit
8b9a1c
------------
8b9a1c
8b9a1c
Patch 7.4.012
8b9a1c
Problem:    MS-Windows: resolving shortcut does not work properly with
8b9a1c
	    multi-byte characters.
8b9a1c
Solution:   Use wide system functions. (Ken Takata)
8b9a1c
Files:	    src/os_mswin.c
8b9a1c
8b9a1c
8b9a1c
*** ../vim-7.4.011/src/os_mswin.c	2013-06-16 16:41:11.000000000 +0200
8b9a1c
--- src/os_mswin.c	2013-08-30 16:43:23.000000000 +0200
8b9a1c
***************
8b9a1c
*** 1761,1769 ****
8b9a1c
      IPersistFile	*ppf = NULL;
8b9a1c
      OLECHAR		wsz[MAX_PATH];
8b9a1c
      WIN32_FIND_DATA	ffd; // we get those free of charge
8b9a1c
!     TCHAR		buf[MAX_PATH]; // could have simply reused 'wsz'...
8b9a1c
      char_u		*rfname = NULL;
8b9a1c
      int			len;
8b9a1c
  
8b9a1c
      /* Check if the file name ends in ".lnk". Avoid calling
8b9a1c
       * CoCreateInstance(), it's quite slow. */
8b9a1c
--- 1761,1773 ----
8b9a1c
      IPersistFile	*ppf = NULL;
8b9a1c
      OLECHAR		wsz[MAX_PATH];
8b9a1c
      WIN32_FIND_DATA	ffd; // we get those free of charge
8b9a1c
!     CHAR		buf[MAX_PATH]; // could have simply reused 'wsz'...
8b9a1c
      char_u		*rfname = NULL;
8b9a1c
      int			len;
8b9a1c
+ # ifdef FEAT_MBYTE
8b9a1c
+     IShellLinkW		*pslw = NULL;
8b9a1c
+     WIN32_FIND_DATAW	ffdw; // we get those free of charge
8b9a1c
+ # endif
8b9a1c
  
8b9a1c
      /* Check if the file name ends in ".lnk". Avoid calling
8b9a1c
       * CoCreateInstance(), it's quite slow. */
8b9a1c
***************
8b9a1c
*** 1775,1792 ****
8b9a1c
  
8b9a1c
      CoInitialize(NULL);
8b9a1c
  
8b9a1c
      // create a link manager object and request its interface
8b9a1c
      hr = CoCreateInstance(
8b9a1c
  	    &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
8b9a1c
  	    &IID_IShellLink, (void**)&psl;;
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_error;
8b9a1c
  
8b9a1c
      // Get a pointer to the IPersistFile interface.
8b9a1c
      hr = psl->lpVtbl->QueryInterface(
8b9a1c
  	    psl, &IID_IPersistFile, (void**)&ppf);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_error;
8b9a1c
  
8b9a1c
      // full path string must be in Unicode.
8b9a1c
      MultiByteToWideChar(CP_ACP, 0, fname, -1, wsz, MAX_PATH);
8b9a1c
--- 1779,1840 ----
8b9a1c
  
8b9a1c
      CoInitialize(NULL);
8b9a1c
  
8b9a1c
+ # ifdef FEAT_MBYTE
8b9a1c
+     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
8b9a1c
+     {
8b9a1c
+ 	// create a link manager object and request its interface
8b9a1c
+ 	hr = CoCreateInstance(
8b9a1c
+ 		&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
8b9a1c
+ 		&IID_IShellLinkW, (void**)&pslw);
8b9a1c
+ 	if (hr == S_OK)
8b9a1c
+ 	{
8b9a1c
+ 	    WCHAR	*p = enc_to_utf16(fname, NULL);
8b9a1c
+ 
8b9a1c
+ 	    if (p != NULL)
8b9a1c
+ 	    {
8b9a1c
+ 		// Get a pointer to the IPersistFile interface.
8b9a1c
+ 		hr = pslw->lpVtbl->QueryInterface(
8b9a1c
+ 			pslw, &IID_IPersistFile, (void**)&ppf);
8b9a1c
+ 		if (hr != S_OK)
8b9a1c
+ 		    goto shortcut_errorw;
8b9a1c
+ 
8b9a1c
+ 		// "load" the name and resolve the link
8b9a1c
+ 		hr = ppf->lpVtbl->Load(ppf, p, STGM_READ);
8b9a1c
+ 		if (hr != S_OK)
8b9a1c
+ 		    goto shortcut_errorw;
8b9a1c
+ #  if 0  // This makes Vim wait a long time if the target does not exist.
8b9a1c
+ 		hr = pslw->lpVtbl->Resolve(pslw, NULL, SLR_NO_UI);
8b9a1c
+ 		if (hr != S_OK)
8b9a1c
+ 		    goto shortcut_errorw;
8b9a1c
+ #  endif
8b9a1c
+ 
8b9a1c
+ 		// Get the path to the link target.
8b9a1c
+ 		ZeroMemory(wsz, MAX_PATH * sizeof(WCHAR));
8b9a1c
+ 		hr = pslw->lpVtbl->GetPath(pslw, wsz, MAX_PATH, &ffdw, 0);
8b9a1c
+ 		if (hr == S_OK && wsz[0] != NUL)
8b9a1c
+ 		    rfname = utf16_to_enc(wsz, NULL);
8b9a1c
+ 
8b9a1c
+ shortcut_errorw:
8b9a1c
+ 		vim_free(p);
8b9a1c
+ 		if (hr == S_OK)
8b9a1c
+ 		    goto shortcut_end;
8b9a1c
+ 	    }
8b9a1c
+ 	}
8b9a1c
+ 	/* Retry with non-wide function (for Windows 98). */
8b9a1c
+     }
8b9a1c
+ # endif
8b9a1c
      // create a link manager object and request its interface
8b9a1c
      hr = CoCreateInstance(
8b9a1c
  	    &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
8b9a1c
  	    &IID_IShellLink, (void**)&psl;;
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_end;
8b9a1c
  
8b9a1c
      // Get a pointer to the IPersistFile interface.
8b9a1c
      hr = psl->lpVtbl->QueryInterface(
8b9a1c
  	    psl, &IID_IPersistFile, (void**)&ppf);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_end;
8b9a1c
  
8b9a1c
      // full path string must be in Unicode.
8b9a1c
      MultiByteToWideChar(CP_ACP, 0, fname, -1, wsz, MAX_PATH);
8b9a1c
***************
8b9a1c
*** 1794,1805 ****
8b9a1c
      // "load" the name and resolve the link
8b9a1c
      hr = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_error;
8b9a1c
! #if 0  // This makes Vim wait a long time if the target doesn't exist.
8b9a1c
      hr = psl->lpVtbl->Resolve(psl, NULL, SLR_NO_UI);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_error;
8b9a1c
! #endif
8b9a1c
  
8b9a1c
      // Get the path to the link target.
8b9a1c
      ZeroMemory(buf, MAX_PATH);
8b9a1c
--- 1842,1853 ----
8b9a1c
      // "load" the name and resolve the link
8b9a1c
      hr = ppf->lpVtbl->Load(ppf, wsz, STGM_READ);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_end;
8b9a1c
! # if 0  // This makes Vim wait a long time if the target doesn't exist.
8b9a1c
      hr = psl->lpVtbl->Resolve(psl, NULL, SLR_NO_UI);
8b9a1c
      if (hr != S_OK)
8b9a1c
! 	goto shortcut_end;
8b9a1c
! # endif
8b9a1c
  
8b9a1c
      // Get the path to the link target.
8b9a1c
      ZeroMemory(buf, MAX_PATH);
8b9a1c
***************
8b9a1c
*** 1807,1818 ****
8b9a1c
      if (hr == S_OK && buf[0] != NUL)
8b9a1c
  	rfname = vim_strsave(buf);
8b9a1c
  
8b9a1c
! shortcut_error:
8b9a1c
      // Release all interface pointers (both belong to the same object)
8b9a1c
      if (ppf != NULL)
8b9a1c
  	ppf->lpVtbl->Release(ppf);
8b9a1c
      if (psl != NULL)
8b9a1c
  	psl->lpVtbl->Release(psl);
8b9a1c
  
8b9a1c
      CoUninitialize();
8b9a1c
      return rfname;
8b9a1c
--- 1855,1870 ----
8b9a1c
      if (hr == S_OK && buf[0] != NUL)
8b9a1c
  	rfname = vim_strsave(buf);
8b9a1c
  
8b9a1c
! shortcut_end:
8b9a1c
      // Release all interface pointers (both belong to the same object)
8b9a1c
      if (ppf != NULL)
8b9a1c
  	ppf->lpVtbl->Release(ppf);
8b9a1c
      if (psl != NULL)
8b9a1c
  	psl->lpVtbl->Release(psl);
8b9a1c
+ # ifdef FEAT_MBYTE
8b9a1c
+     if (pslw != NULL)
8b9a1c
+ 	pslw->lpVtbl->Release(pslw);
8b9a1c
+ # endif
8b9a1c
  
8b9a1c
      CoUninitialize();
8b9a1c
      return rfname;
8b9a1c
*** ../vim-7.4.011/src/version.c	2013-08-30 16:35:41.000000000 +0200
8b9a1c
--- src/version.c	2013-08-30 16:39:40.000000000 +0200
8b9a1c
***************
8b9a1c
*** 740,741 ****
8b9a1c
--- 740,743 ----
8b9a1c
  {   /* Add new patch number below this line */
8b9a1c
+ /**/
8b9a1c
+     12,
8b9a1c
  /**/
8b9a1c
8b9a1c
-- 
8b9a1c
hundred-and-one symptoms of being an internet addict:
8b9a1c
142. You dream about creating the world's greatest web site.
8b9a1c
8b9a1c
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
8b9a1c
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
8b9a1c
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
8b9a1c
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///