Alexandre Julliard : user: Added fast W->A mapping for EM_GETLINE.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 18 09:43:55 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: dd442faa2e44768652cc996b3b8cd69b53c0dcaf
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=dd442faa2e44768652cc996b3b8cd69b53c0dcaf

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu May 18 12:20:14 2006 +0200

user: Added fast W->A mapping for EM_GETLINE.

---

 dlls/user/winproc.c |   68 +++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 45 deletions(-)

diff --git a/dlls/user/winproc.c b/dlls/user/winproc.c
index d4b0db5..4fbb4c0 100644
--- a/dlls/user/winproc.c
+++ b/dlls/user/winproc.c
@@ -992,17 +992,6 @@ static INT WINPROC_MapMsg32WTo32A( HWND 
 {
     switch(msg)
     {
-/* Multiline edit */
-    case EM_GETLINE:
-        { WORD len = (WORD)*plparam;
-          LPARAM *ptr = HeapAlloc( GetProcessHeap(), 0, sizeof(LPARAM) + sizeof (WORD) + len*sizeof(CHAR) );
-          if (!ptr) return -1;
-          *ptr++ = *plparam;  /* Store previous lParam */
-          *((WORD *) ptr) = len;   /* Store the length */
-          *plparam = (LPARAM)ptr;
-        }
-        return 1;
-
     case WM_CHARTOITEM:
     case WM_MENUCHAR:
     case WM_CHAR:
@@ -1040,32 +1029,6 @@ static INT WINPROC_MapMsg32WTo32A( HWND 
 }
 
 
-/**********************************************************************
- *	     WINPROC_UnmapMsg32WTo32A
- *
- * Unmap a message that was mapped from Unicode to Ansi.
- */
-static LRESULT WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result )
-{
-    switch(msg)
-    {
-/* Multiline edit */
-    case EM_GETLINE:
-        {
-            LPARAM * ptr = (LPARAM *)lParam - 1;  /* get the old lparam */
-            WORD len = *(WORD *)ptr;
-            if (len)
-            {
-                result = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, result, (LPWSTR)*ptr, len );
-                if (result < len) ((LPWSTR)*ptr)[result] = 0;
-            }
-            HeapFree( GetProcessHeap(), 0, ptr );
-        }
-        break;
-    }
-    return result;
-}
-
 static UINT convert_handle_16_to_32(HANDLE16 src, unsigned int flags)
 {
     HANDLE      dst;
@@ -3021,6 +2984,29 @@ static LRESULT WINPROC_CallProc32WTo32A(
         else ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
         break;
 
+/* Multiline edit */
+    case EM_GETLINE:
+        {
+            char *ptr, buffer[512];
+            WORD len = *(WORD *)lParam;
+            DWORD result;
+
+            if (!(ptr = get_buffer( buffer, sizeof(buffer), len * 2 ))) break;
+            *((WORD *)ptr) = len * 2;   /* store the length */
+            ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, (LPARAM)ptr );
+            result = dialog ? GetWindowLongPtrW( hwnd, DWLP_MSGRESULT ) : ret;
+            if (result)
+            {
+                RtlMultiByteToUnicodeN( (LPWSTR)lParam, len*sizeof(WCHAR), &result, buffer, result );
+                result /= sizeof(WCHAR);
+                if (result < len) ((LPWSTR)lParam)[result] = 0;
+                if (dialog) SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
+                else ret = result;
+            }
+            free_buffer( buffer, ptr );
+        }
+        break;
+
     default:
         if ((unmap = WINPROC_MapMsg32WTo32A( hwnd, msg, &wParam, &lParam )) == -1) {
             ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",
@@ -3028,14 +3014,6 @@ static LRESULT WINPROC_CallProc32WTo32A(
             return 0;
         }
         ret = WINPROC_CallWndProc( func, hwnd, msg, wParam, lParam );
-        if (!unmap) break;
-        if (dialog)
-        {
-            LRESULT result = GetWindowLongPtrW( hwnd, DWLP_MSGRESULT );
-            result = WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam, result );
-            SetWindowLongPtrW( hwnd, DWLP_MSGRESULT, result );
-        }
-        else ret = WINPROC_UnmapMsg32WTo32A( hwnd, msg, wParam, lParam, ret );
         break;
     }
 




More information about the wine-cvs mailing list