Rob Shearman : riched20: Always treat the nCount variable in the EM_GETTEXTEX handler as a character count .
Alexandre Julliard
julliard at winehq.org
Mon Jan 21 05:59:03 CST 2008
Module: wine
Branch: master
Commit: 4bff248783aa59965beb0be7883272d1671c3034
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4bff248783aa59965beb0be7883272d1671c3034
Author: Rob Shearman <rob at codeweavers.com>
Date: Fri Jan 18 13:24:26 2008 +0000
riched20: Always treat the nCount variable in the EM_GETTEXTEX handler as a character count.
Convert ex->cb into a character count before assigning it to nCount.
Remove some dubious minus ones that would result in different character
counts for the Unicode and ANSI paths.
---
dlls/riched20/editor.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index a954500..705c5a1 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -2101,7 +2101,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
case EM_GETTEXTEX:
{
GETTEXTEX *ex = (GETTEXTEX*)wParam;
- int nStart, nCount;
+ int nStart, nCount; /* in chars */
if (ex->flags & ~(GT_SELECTION | GT_USECRLF))
FIXME("GETTEXTEX flags 0x%08x not supported\n", ex->flags & ~(GT_SELECTION | GT_USECRLF));
@@ -2110,12 +2110,11 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
{
ME_GetSelection(editor, &nStart, &nCount);
nCount -= nStart;
- nCount = min(nCount, ex->cb - 1);
}
else
{
nStart = 0;
- nCount = ex->cb - 1;
+ nCount = 0x7fffffff;
}
if (ex->codepage == 1200)
{
@@ -2127,11 +2126,14 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
/* potentially each char may be a CR, why calculate the exact value with O(N) when
we can just take a bigger buffer? :) */
int crlfmul = (ex->flags & GT_USECRLF) ? 2 : 1;
- LPWSTR buffer = heap_alloc((crlfmul*nCount + 1) * sizeof(WCHAR));
+ LPWSTR buffer;
DWORD buflen = ex->cb;
LRESULT rc;
DWORD flags = 0;
+ nCount = min(nCount, ex->cb - 1);
+ buffer = heap_alloc((crlfmul*nCount + 1) * sizeof(WCHAR));
+
buflen = ME_GetTextW(editor, buffer, nStart, nCount, ex->flags & GT_USECRLF);
rc = WideCharToMultiByte(ex->codepage, flags, buffer, -1, (LPSTR)lParam, ex->cb, ex->lpDefaultChar, ex->lpUsedDefaultChar);
if (rc) rc--; /* do not count 0 terminator */
More information about the wine-cvs
mailing list