Dylan Smith : richedit: Got rid of ME_GetCharFwd and ME_GetCharBack.
Alexandre Julliard
julliard at winehq.org
Mon Feb 9 10:29:30 CST 2009
Module: wine
Branch: master
Commit: 1eb0f73ab026a302cdde1fa4fe7a7d7e9cb86711
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1eb0f73ab026a302cdde1fa4fe7a7d7e9cb86711
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Sat Feb 7 13:21:23 2009 -0500
richedit: Got rid of ME_GetCharFwd and ME_GetCharBack.
These two functions were being used for simple operations, to get the
first or last character when pre-computing flags for splitting runs.
The call to ME_GetCharBack wasn't even giving the correct result, it
would always return -1 since it is being called with nPos of 0.
This patch simplifies the code by removing the functions and getting the
characters directly from the string.
---
dlls/riched20/editor.h | 2 --
dlls/riched20/run.c | 19 ++++++++++---------
dlls/riched20/string.c | 26 --------------------------
3 files changed, 10 insertions(+), 37 deletions(-)
diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 2e53c22..4c87eed 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -100,8 +100,6 @@ int ME_IsSplitable(const ME_String *s);
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar);
int ME_FindWhitespaceV(ME_String *s, int nVChar);
int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code);
-int ME_GetCharFwd(const ME_String *s, int nPos); /* get char starting from start */
-int ME_GetCharBack(const ME_String *s, int nPos); /* get char starting from \0 */
int ME_StrRelPos(const ME_String *s, int nVChar, int *pRelChars);
int ME_StrRelPos2(const ME_String *s, int nVChar, int nRelChars);
int ME_PosToVPos(const ME_String *s, int nPos);
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index ed066ea..c36f25f 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -406,38 +406,39 @@ ME_InsertRunAtCursor(ME_TextEditor *editor, ME_Cursor *cursor, ME_Style *style,
/******************************************************************************
* ME_UpdateRunFlags
- *
+ *
* Determine some of run attributes given its content (style, text content).
- * Some flags cannot be determined by this function (MERF_GRAPHICS,
- * MERF_ENDPARA)
- */
+ * Some flags cannot be determined by this function (MERF_GRAPHICS,
+ * MERF_ENDPARA)
+ */
void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
{
- assert(run->nCharOfs != -1);
+ ME_String *strText = run->strText;
+ assert(run->nCharOfs >= 0);
if (RUN_IS_HIDDEN(run) || run->nFlags & MERF_TABLESTART)
run->nFlags |= MERF_HIDDEN;
else
run->nFlags &= ~MERF_HIDDEN;
- if (ME_IsSplitable(run->strText))
+ if (ME_IsSplitable(strText))
run->nFlags |= MERF_SPLITTABLE;
else
run->nFlags &= ~MERF_SPLITTABLE;
if (!(run->nFlags & MERF_NOTEXT)) {
- if (ME_IsWhitespaces(run->strText))
+ if (ME_IsWhitespaces(strText))
run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
else
{
run->nFlags &= ~MERF_WHITESPACE;
- if (ME_IsWSpace(ME_GetCharFwd(run->strText,0)))
+ if (ME_IsWSpace(strText->szData[0]))
run->nFlags |= MERF_STARTWHITE;
else
run->nFlags &= ~MERF_STARTWHITE;
- if (ME_IsWSpace(ME_GetCharBack(run->strText,0)))
+ if (ME_IsWSpace(strText->szData[strText->nLen - 1]))
run->nFlags |= MERF_ENDWHITE;
else
run->nFlags &= ~MERF_ENDWHITE;
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 7cc0001..2b6b559 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -186,32 +186,6 @@ void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
s->nLen -= (end_ofs - nVChar);
}
-int ME_GetCharFwd(const ME_String *s, int nPos)
-{
- int nVPos = 0;
-
- assert(nPos < s->nLen);
- if (nPos)
- nVPos = ME_StrRelPos2(s, nVPos, nPos);
-
- if (nVPos < s->nLen)
- return s->szData[nVPos];
- return -1;
-}
-
-int ME_GetCharBack(const ME_String *s, int nPos)
-{
- int nVPos = s->nLen;
-
- assert(nPos < s->nLen);
- if (nPos)
- nVPos = ME_StrRelPos2(s, nVPos, -nPos);
-
- if (nVPos < s->nLen)
- return s->szData[nVPos];
- return -1;
-}
-
int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) {
int i;
for (i = nVChar; i<s->nLen && ME_IsWSpace(s->szData[i]); i++)
More information about the wine-cvs
mailing list