Michael Jung : riched20: Don't append '\r' to the last paragraph in EM_GETTEXTEX.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 8 15:38:09 CDT 2006


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

Author: Michael Jung <mjung at iss.tu-darmstadt.de>
Date:   Sun Apr 23 21:09:30 2006 +0200

riched20: Don't append '\r' to the last paragraph in EM_GETTEXTEX.

---

 dlls/riched20/editor.c       |   29 +++++++++++++++++------------
 dlls/riched20/tests/editor.c |    5 +----
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 3bc27a4..d73690c 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1956,7 +1956,7 @@ LRESULT WINAPI RichEditANSIWndProc(HWND 
       DWORD flags = 0;
 
       buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF);
-      rc = WideCharToMultiByte(ex->codepage, flags, buffer, buflen, (LPSTR)lParam, ex->cb, ex->lpDefaultChar, ex->lpUsedDefaultChar);
+      rc = WideCharToMultiByte(ex->codepage, flags, buffer, -1, (LPSTR)lParam, ex->cb, ex->lpDefaultChar, ex->lpUsedDefaultChar);
 
       HeapFree(GetProcessHeap(),0,buffer);
       return rc;
@@ -2499,21 +2499,26 @@ int ME_GetTextW(ME_TextEditor *editor, W
     int nLen = ME_StrLen(item->member.run.strText);
     if (nLen > nChars)
       nLen = nChars;
-      
+
     if (item->member.run.nFlags & MERF_ENDPARA)
     {
-      *buffer = '\r';
-      if (bCRLF)
-      {
-        *(++buffer) = '\n';
-        nWritten++;
+      if (!ME_FindItemFwd(item, diRun))
+        /* No '\r' is appended to the last paragraph. */
+        nLen = 0;
+      else {
+        *buffer = '\r';
+        if (bCRLF)
+        {
+          *(++buffer) = '\n';
+          nWritten++;
+        }
+        assert(nLen == 1);
+        /* our end paragraph consists of 2 characters now */
+        if (editor->bEmulateVersion10)
+          nChars--;
       }
-      assert(nLen == 1);
-      /* our end paragraph consists of 2 characters now */
-      if (editor->bEmulateVersion10)
-        nChars--;
     }
-    else      
+    else
       CopyMemory(buffer, item->member.run.strText->szData, sizeof(WCHAR)*nLen);
     nChars -= nLen;
     nWritten += nLen;
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index fa5abca..6b80903 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -494,7 +494,6 @@ static void test_TM_PLAINTEXT()
   DestroyWindow(hwndRichEdit);
 }
 
-/* FIXME: Extra '\r' appended at end of gotten text*/
 static void test_WM_GETTEXT()
 {
     HWND hwndRichEdit = new_richedit(NULL);
@@ -505,10 +504,8 @@ static void test_WM_GETTEXT()
     SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
     SendMessage(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
     result = strcmp(buffer,text);
-    todo_wine{
-      ok(result == 0, 
+    ok(result == 0, 
         "WM_GETTEXT: settext and gettext differ. strcmp: %d\n", result);
-    }
 }
 
 /* FIXME: need to test unimplemented options and robustly test wparam */




More information about the wine-cvs mailing list