updated for version 7.4.142 v7.4.142
authorBram Moolenaar <Bram@vim.org>
Sun, 12 Jan 2014 12:24:51 +0000 (13:24 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 12 Jan 2014 12:24:51 +0000 (13:24 +0100)
Problem:    On MS-Windows 8 IME input doen't work correctly.
Solution:   Work around the problem. (Nobuhiro Takasaki)

src/os_win32.c
src/version.c

index 4feb69791a05a4518d6002ca3306a6215d90612b..e9ec5f7c06da557723140d3242012b632a50476d 100644 (file)
@@ -234,56 +234,42 @@ static char_u *exe_path = NULL;
 
 /*
  * Version of ReadConsoleInput() that works with IME.
+ * Works around problems on Windows 8.
  */
     static BOOL
 read_console_input(
-    HANDLE hConsoleInput,
-    PINPUT_RECORD lpBuffer,
-    DWORD nLength,
-    LPDWORD lpNumberOfEventsRead)
+    HANDLE         hInput,
+    INPUT_RECORD    *lpBuffer,
+    DWORD          nLength,
+    LPDWORD        lpEvents)
 {
     enum
     {
-       IRSIZE = 10, /* rough value */
+       IRSIZE = 10
     };
-    static INPUT_RECORD irCache[IRSIZE];
+    static INPUT_RECORD s_irCache[IRSIZE];
     static DWORD s_dwIndex = 0;
     static DWORD s_dwMax = 0;
-
-    if (hConsoleInput == NULL || lpBuffer == NULL)
-       return ReadConsoleInput(hConsoleInput, lpBuffer, nLength,
-                                                       lpNumberOfEventsRead);
-
-    if (nLength == -1)
-    {
-       if (s_dwMax == 0)
-       {
-           PeekConsoleInput(hConsoleInput, lpBuffer, 1, lpNumberOfEventsRead);
-           if (*lpNumberOfEventsRead == 0)
-               return FALSE;
-           ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
-           s_dwIndex = 0;
-       }
-       ((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
-       *lpNumberOfEventsRead = 1;
-       return TRUE;
-    }
+    DWORD dwEvents;
 
     if (s_dwMax == 0)
     {
-       ReadConsoleInput(hConsoleInput, irCache, IRSIZE, &s_dwMax);
+       if (nLength == -1)
+           return PeekConsoleInput(hInput, lpBuffer, 1, lpEvents);
+       if (!ReadConsoleInput(hInput, s_irCache, IRSIZE, &dwEvents))
+           return FALSE;
        s_dwIndex = 0;
-       if (s_dwMax == 0)
+       s_dwMax = dwEvents;
+       if (dwEvents == 0)
        {
-           *lpNumberOfEventsRead = 0;
-           return FALSE;
+           *lpEvents = 0;
+           return TRUE;
        }
     }
-
-    ((PINPUT_RECORD)lpBuffer)[0] = irCache[s_dwIndex];
-    if (++s_dwIndex == s_dwMax)
+    *lpBuffer = s_irCache[s_dwIndex];
+    if (nLength != -1 && ++s_dwIndex >= s_dwMax)
        s_dwMax = 0;
-    *lpNumberOfEventsRead = 1;
+    *lpEvents = 1;
     return TRUE;
 }
 
@@ -292,13 +278,12 @@ read_console_input(
  */
     static BOOL
 peek_console_input(
-    HANDLE hConsoleInput,
-    PINPUT_RECORD lpBuffer,
-    DWORD nLength,
-    LPDWORD lpNumberOfEventsRead)
+    HANDLE         hInput,
+    INPUT_RECORD    *lpBuffer,
+    DWORD          nLength,
+    LPDWORD        lpEvents)
 {
-    return read_console_input(hConsoleInput, lpBuffer, -1,
-                                                       lpNumberOfEventsRead);
+    return read_console_input(hInput, lpBuffer, -1, lpEvents);
 }
 
     static void
@@ -585,10 +570,10 @@ static PSETHANDLEINFORMATION pSetHandleInformation;
     static BOOL
 win32_enable_privilege(LPTSTR lpszPrivilege, BOOL bEnable)
 {
-    BOOL             bResult;
-    LUID             luid;
-    HANDLE           hToken;
-    TOKEN_PRIVILEGES tokenPrivileges;
+    BOOL               bResult;
+    LUID               luid;
+    HANDLE             hToken;
+    TOKEN_PRIVILEGES   tokenPrivileges;
 
     if (!OpenProcessToken(GetCurrentProcess(),
                TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
index 1fd98ead21acec0956b09c6d893b5f1c028dafa0..a468a79c31d1a6840e4e7afdc9ab03628a6fbc53 100644 (file)
@@ -738,6 +738,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    142,
 /**/
     141,
 /**/