Karsten Hopp ea0b27
To: vim_dev@googlegroups.com
Karsten Hopp ea0b27
Subject: Patch 7.3.767
Karsten Hopp ea0b27
Fcc: outbox
Karsten Hopp ea0b27
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp ea0b27
Mime-Version: 1.0
Karsten Hopp ea0b27
Content-Type: text/plain; charset=UTF-8
Karsten Hopp ea0b27
Content-Transfer-Encoding: 8bit
Karsten Hopp ea0b27
------------
Karsten Hopp ea0b27
Karsten Hopp ea0b27
Patch 7.3.767
Karsten Hopp ea0b27
Problem:    (Win32) The _errno used for iconv may be the wrong one.
Karsten Hopp ea0b27
Solution:   Use the _errno from iconv.dll. (Ken Takata)
Karsten Hopp ea0b27
Files:	    src/mbyte.c
Karsten Hopp ea0b27
Karsten Hopp ea0b27
Karsten Hopp ea0b27
*** ../vim-7.3.766/src/mbyte.c	2012-09-18 18:03:33.000000000 +0200
Karsten Hopp ea0b27
--- src/mbyte.c	2013-01-17 14:33:42.000000000 +0100
Karsten Hopp ea0b27
***************
Karsten Hopp ea0b27
*** 3242,3248 ****
Karsten Hopp ea0b27
  
Karsten Hopp ea0b27
  /*
Karsten Hopp ea0b27
   * Version of strnicmp() that handles multi-byte characters.
Karsten Hopp ea0b27
!  * Needed for Big5, Sjift-JIS and UTF-8 encoding.  Other DBCS encodings can
Karsten Hopp ea0b27
   * probably use strnicmp(), because there are no ASCII characters in the
Karsten Hopp ea0b27
   * second byte.
Karsten Hopp ea0b27
   * Returns zero if s1 and s2 are equal (ignoring case), the difference between
Karsten Hopp ea0b27
--- 3242,3248 ----
Karsten Hopp ea0b27
  
Karsten Hopp ea0b27
  /*
Karsten Hopp ea0b27
   * Version of strnicmp() that handles multi-byte characters.
Karsten Hopp ea0b27
!  * Needed for Big5, Shift-JIS and UTF-8 encoding.  Other DBCS encodings can
Karsten Hopp ea0b27
   * probably use strnicmp(), because there are no ASCII characters in the
Karsten Hopp ea0b27
   * second byte.
Karsten Hopp ea0b27
   * Returns zero if s1 and s2 are equal (ignoring case), the difference between
Karsten Hopp ea0b27
***************
Karsten Hopp ea0b27
*** 4294,4299 ****
Karsten Hopp ea0b27
--- 4294,4337 ----
Karsten Hopp ea0b27
  #  endif
Karsten Hopp ea0b27
  
Karsten Hopp ea0b27
  /*
Karsten Hopp ea0b27
+  * Get the address of 'funcname' which is imported by 'hInst' DLL.
Karsten Hopp ea0b27
+  */
Karsten Hopp ea0b27
+     static void *
Karsten Hopp ea0b27
+ get_iconv_import_func(HINSTANCE hInst, const char *funcname)
Karsten Hopp ea0b27
+ {
Karsten Hopp ea0b27
+     PBYTE			pImage = (PBYTE)hInst;
Karsten Hopp ea0b27
+     PIMAGE_DOS_HEADER		pDOS = (PIMAGE_DOS_HEADER)hInst;
Karsten Hopp ea0b27
+     PIMAGE_NT_HEADERS		pPE;
Karsten Hopp ea0b27
+     PIMAGE_IMPORT_DESCRIPTOR	pImpDesc;
Karsten Hopp ea0b27
+     PIMAGE_THUNK_DATA		pIAT;	    /* Import Address Table */
Karsten Hopp ea0b27
+     PIMAGE_THUNK_DATA		pINT;	    /* Import Name Table */
Karsten Hopp ea0b27
+     PIMAGE_IMPORT_BY_NAME	pImpName;
Karsten Hopp ea0b27
+ 
Karsten Hopp ea0b27
+     if (pDOS->e_magic != IMAGE_DOS_SIGNATURE)
Karsten Hopp ea0b27
+ 	return NULL;
Karsten Hopp ea0b27
+     pPE = (PIMAGE_NT_HEADERS)(pImage + pDOS->e_lfanew);
Karsten Hopp ea0b27
+     if (pPE->Signature != IMAGE_NT_SIGNATURE)
Karsten Hopp ea0b27
+ 	return NULL;
Karsten Hopp ea0b27
+     pImpDesc = (PIMAGE_IMPORT_DESCRIPTOR)(pImage
Karsten Hopp ea0b27
+ 	    + pPE->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT]
Karsten Hopp ea0b27
+ 							    .VirtualAddress);
Karsten Hopp ea0b27
+     for (; pImpDesc->FirstThunk; ++pImpDesc)
Karsten Hopp ea0b27
+     {
Karsten Hopp ea0b27
+ 	pIAT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->FirstThunk);
Karsten Hopp ea0b27
+ 	pINT = (PIMAGE_THUNK_DATA)(pImage + pImpDesc->OriginalFirstThunk);
Karsten Hopp ea0b27
+ 	for (; pIAT->u1.Function; ++pIAT, ++pINT)
Karsten Hopp ea0b27
+ 	{
Karsten Hopp ea0b27
+ 	    if (IMAGE_SNAP_BY_ORDINAL(pINT->u1.Ordinal))
Karsten Hopp ea0b27
+ 		continue;
Karsten Hopp ea0b27
+ 	    pImpName = (PIMAGE_IMPORT_BY_NAME)(pImage + pINT->u1.AddressOfData);
Karsten Hopp ea0b27
+ 	    if (strcmp(pImpName->Name, funcname) == 0)
Karsten Hopp ea0b27
+ 		return (void *)pIAT->u1.Function;
Karsten Hopp ea0b27
+ 	}
Karsten Hopp ea0b27
+     }
Karsten Hopp ea0b27
+     return NULL;
Karsten Hopp ea0b27
+ }
Karsten Hopp ea0b27
+ 
Karsten Hopp ea0b27
+ /*
Karsten Hopp ea0b27
   * Try opening the iconv.dll and return TRUE if iconv() can be used.
Karsten Hopp ea0b27
   */
Karsten Hopp ea0b27
      int
Karsten Hopp ea0b27
***************
Karsten Hopp ea0b27
*** 4326,4332 ****
Karsten Hopp ea0b27
      iconv_open	= (void *)GetProcAddress(hIconvDLL, "libiconv_open");
Karsten Hopp ea0b27
      iconv_close	= (void *)GetProcAddress(hIconvDLL, "libiconv_close");
Karsten Hopp ea0b27
      iconvctl	= (void *)GetProcAddress(hIconvDLL, "libiconvctl");
Karsten Hopp ea0b27
!     iconv_errno	= (void *)GetProcAddress(hMsvcrtDLL, "_errno");
Karsten Hopp ea0b27
      if (iconv == NULL || iconv_open == NULL || iconv_close == NULL
Karsten Hopp ea0b27
  	    || iconvctl == NULL || iconv_errno == NULL)
Karsten Hopp ea0b27
      {
Karsten Hopp ea0b27
--- 4364,4372 ----
Karsten Hopp ea0b27
      iconv_open	= (void *)GetProcAddress(hIconvDLL, "libiconv_open");
Karsten Hopp ea0b27
      iconv_close	= (void *)GetProcAddress(hIconvDLL, "libiconv_close");
Karsten Hopp ea0b27
      iconvctl	= (void *)GetProcAddress(hIconvDLL, "libiconvctl");
Karsten Hopp ea0b27
!     iconv_errno	= get_iconv_import_func(hIconvDLL, "_errno");
Karsten Hopp ea0b27
!     if (iconv_errno == NULL)
Karsten Hopp ea0b27
! 	iconv_errno = (void *)GetProcAddress(hMsvcrtDLL, "_errno");
Karsten Hopp ea0b27
      if (iconv == NULL || iconv_open == NULL || iconv_close == NULL
Karsten Hopp ea0b27
  	    || iconvctl == NULL || iconv_errno == NULL)
Karsten Hopp ea0b27
      {
Karsten Hopp ea0b27
*** ../vim-7.3.766/src/version.c	2013-01-17 14:09:39.000000000 +0100
Karsten Hopp ea0b27
--- src/version.c	2013-01-17 14:34:19.000000000 +0100
Karsten Hopp ea0b27
***************
Karsten Hopp ea0b27
*** 727,728 ****
Karsten Hopp ea0b27
--- 727,730 ----
Karsten Hopp ea0b27
  {   /* Add new patch number below this line */
Karsten Hopp ea0b27
+ /**/
Karsten Hopp ea0b27
+     767,
Karsten Hopp ea0b27
  /**/
Karsten Hopp ea0b27
Karsten Hopp ea0b27
-- 
Karsten Hopp ea0b27
FIRST HEAD:  Oh! quick! get the sword out I want to cut his head off.
Karsten Hopp ea0b27
THIRD HEAD:  Oh, cut your own head off.
Karsten Hopp ea0b27
SECOND HEAD: Yes - do us all a favour.
Karsten Hopp ea0b27
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp ea0b27
Karsten Hopp ea0b27
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp ea0b27
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp ea0b27
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp ea0b27
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///