Blame SOURCES/7.4.015

22c937
To: vim_dev@googlegroups.com
22c937
Subject: Patch 7.4.015
22c937
Fcc: outbox
22c937
From: Bram Moolenaar <Bram@moolenaar.net>
22c937
Mime-Version: 1.0
22c937
Content-Type: text/plain; charset=UTF-8
22c937
Content-Transfer-Encoding: 8bit
22c937
------------
22c937
22c937
Patch 7.4.015
22c937
Problem:    MS-Windows: Detecting node type does not work for multi-byte
22c937
	    characters.
22c937
Solution:   Use wide character function when needed. (Ken Takata)
22c937
Files:	    src/os_win32.c
22c937
22c937
22c937
*** ../vim-7.4.014/src/os_win32.c	2013-08-10 12:39:12.000000000 +0200
22c937
--- src/os_win32.c	2013-08-30 17:09:47.000000000 +0200
22c937
***************
22c937
*** 3107,3112 ****
22c937
--- 3107,3115 ----
22c937
  {
22c937
      HANDLE	hFile;
22c937
      int		type;
22c937
+ #ifdef FEAT_MBYTE
22c937
+     WCHAR	*wn = NULL;
22c937
+ #endif
22c937
  
22c937
      /* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
22c937
       * read from it later will cause Vim to hang.  Thus return NODE_WRITABLE
22c937
***************
22c937
*** 3114,3127 ****
22c937
      if (STRNCMP(name, "\\\\.\\", 4) == 0)
22c937
  	return NODE_WRITABLE;
22c937
  
22c937
!     hFile = CreateFile(name,		/* file name */
22c937
! 		GENERIC_WRITE,		/* access mode */
22c937
! 		0,			/* share mode */
22c937
! 		NULL,			/* security descriptor */
22c937
! 		OPEN_EXISTING,		/* creation disposition */
22c937
! 		0,			/* file attributes */
22c937
! 		NULL);			/* handle to template file */
22c937
  
22c937
      if (hFile == INVALID_HANDLE_VALUE)
22c937
  	return NODE_NORMAL;
22c937
  
22c937
--- 3117,3157 ----
22c937
      if (STRNCMP(name, "\\\\.\\", 4) == 0)
22c937
  	return NODE_WRITABLE;
22c937
  
22c937
! #ifdef FEAT_MBYTE
22c937
!     if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
22c937
!     {
22c937
! 	wn = enc_to_utf16(name, NULL);
22c937
! 	if (wn != NULL)
22c937
! 	{
22c937
! 	    hFile = CreateFileW(wn,	/* file name */
22c937
! 			GENERIC_WRITE,	/* access mode */
22c937
! 			0,		/* share mode */
22c937
! 			NULL,		/* security descriptor */
22c937
! 			OPEN_EXISTING,	/* creation disposition */
22c937
! 			0,		/* file attributes */
22c937
! 			NULL);		/* handle to template file */
22c937
! 	    if (hFile == INVALID_HANDLE_VALUE
22c937
! 			      && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
22c937
! 	    {
22c937
! 		/* Retry with non-wide function (for Windows 98). */
22c937
! 		vim_free(wn);
22c937
! 		wn = NULL;
22c937
! 	    }
22c937
! 	}
22c937
!     }
22c937
!     if (wn == NULL)
22c937
! #endif
22c937
! 	hFile = CreateFile(name,	/* file name */
22c937
! 		    GENERIC_WRITE,	/* access mode */
22c937
! 		    0,			/* share mode */
22c937
! 		    NULL,		/* security descriptor */
22c937
! 		    OPEN_EXISTING,	/* creation disposition */
22c937
! 		    0,			/* file attributes */
22c937
! 		    NULL);		/* handle to template file */
22c937
  
22c937
+ #ifdef FEAT_MBYTE
22c937
+     vim_free(wn);
22c937
+ #endif
22c937
      if (hFile == INVALID_HANDLE_VALUE)
22c937
  	return NODE_NORMAL;
22c937
  
22c937
*** ../vim-7.4.014/src/version.c	2013-08-30 17:06:56.000000000 +0200
22c937
--- src/version.c	2013-08-30 17:09:35.000000000 +0200
22c937
***************
22c937
*** 740,741 ****
22c937
--- 740,743 ----
22c937
  {   /* Add new patch number below this line */
22c937
+ /**/
22c937
+     15,
22c937
  /**/
22c937
22c937
-- 
22c937
hundred-and-one symptoms of being an internet addict:
22c937
144. You eagerly await the update of the "Cool Site of the Day."
22c937
22c937
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
22c937
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
22c937
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
22c937
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///