Dylan Smith : richedit: Move implementation of EM_GETTEXTRANGE to its own function.
Alexandre Julliard
julliard at winehq.org
Tue Dec 16 08:40:42 CST 2008
Module: wine
Branch: master
Commit: 4f41972b15b865c792ecebce41f63243bdf5def4
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4f41972b15b865c792ecebce41f63243bdf5def4
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Tue Dec 16 03:43:13 2008 -0500
richedit: Move implementation of EM_GETTEXTRANGE to its own function.
The RichEditWndProc_common function is big enough already by handling
all the window messages, so moving code to handle a message to its own
function makes the code more readable.
---
dlls/riched20/editor.c | 36 +++++++++++++++++++++---------------
1 files changed, 21 insertions(+), 15 deletions(-)
diff --git a/dlls/riched20/editor.c b/dlls/riched20/editor.c
index 55bc9b8..b79fe16 100644
--- a/dlls/riched20/editor.c
+++ b/dlls/riched20/editor.c
@@ -1938,6 +1938,25 @@ ME_FindText(ME_TextEditor *editor, DWORD flags, const CHARRANGE *chrg, const WCH
return -1;
}
+static int ME_GetTextRange(ME_TextEditor *editor, TEXTRANGEW *rng, BOOL unicode)
+{
+ if (unicode)
+ return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin,
+ rng->chrg.cpMax-rng->chrg.cpMin, 0);
+ else
+ {
+ int nLen = rng->chrg.cpMax-rng->chrg.cpMin;
+ WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1);
+ int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0);
+ /* FIXME this is a potential security hole (buffer overrun)
+ if you know more about wchar->mbyte conversion please explain
+ */
+ WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)rng->lpstrText, nLen+1, NULL, NULL);
+ FREE_OBJ(p);
+ return nChars;
+ }
+}
+
typedef struct tagME_GlobalDestStruct
{
HGLOBAL hData;
@@ -3259,7 +3278,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
tr.chrg.cpMin = from;
tr.chrg.cpMax = to;
tr.lpstrText = (WCHAR *)lParam;
- return RichEditWndProc_common(hWnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr, unicode);
+ return ME_GetTextRange(editor, &tr, unicode);
}
case EM_GETSCROLLPOS:
{
@@ -3274,20 +3293,7 @@ static LRESULT RichEditWndProc_common(HWND hWnd, UINT msg, WPARAM wParam,
TRACE("EM_GETTEXTRANGE min=%d max=%d unicode=%d emul1.0=%d length=%d\n",
rng->chrg.cpMin, rng->chrg.cpMax, unicode,
editor->bEmulateVersion10, ME_GetTextLength(editor));
- if (unicode)
- return ME_GetTextW(editor, rng->lpstrText, rng->chrg.cpMin, rng->chrg.cpMax-rng->chrg.cpMin, 0);
- else
- {
- int nLen = rng->chrg.cpMax-rng->chrg.cpMin;
- WCHAR *p = ALLOC_N_OBJ(WCHAR, nLen+1);
- int nChars = ME_GetTextW(editor, p, rng->chrg.cpMin, nLen, 0);
- /* FIXME this is a potential security hole (buffer overrun)
- if you know more about wchar->mbyte conversion please explain
- */
- WideCharToMultiByte(CP_ACP, 0, p, nChars+1, (char *)rng->lpstrText, nLen+1, NULL, NULL);
- FREE_OBJ(p);
- return nChars;
- }
+ return ME_GetTextRange(editor, rng, unicode);
}
case EM_GETLINE:
{
More information about the wine-cvs
mailing list