Huw Davies : riched20: Rewrite the run whitespace test to take a run parameter.

Alexandre Julliard julliard at winehq.org
Thu Jan 31 12:11:42 CST 2013


Module: wine
Branch: master
Commit: 76cfe7dc5018ea9f8572ef0a5adce06c1c838784
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=76cfe7dc5018ea9f8572ef0a5adce06c1c838784

Author: Huw Davies <huw at codeweavers.com>
Date:   Thu Jan 31 13:47:58 2013 +0000

riched20: Rewrite the run whitespace test to take a run parameter.

---

 dlls/riched20/editor.h |    1 -
 dlls/riched20/run.c    |   16 ++++++++++++++--
 dlls/riched20/string.c |   13 -------------
 3 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/dlls/riched20/editor.h b/dlls/riched20/editor.h
index 87dd288..f01494c 100644
--- a/dlls/riched20/editor.h
+++ b/dlls/riched20/editor.h
@@ -104,7 +104,6 @@ ME_String *ME_StrDup(const ME_String *s) DECLSPEC_HIDDEN;
 void ME_DestroyString(ME_String *s) DECLSPEC_HIDDEN;
 void ME_AppendString(ME_String *s1, const ME_String *s2) DECLSPEC_HIDDEN;
 ME_String *ME_VSplitString(ME_String *orig, int nVPos) DECLSPEC_HIDDEN;
-int ME_IsWhitespaces(const ME_String *s) DECLSPEC_HIDDEN;
 int ME_FindNonWhitespaceV(const ME_String *s, int nVChar) DECLSPEC_HIDDEN;
 int ME_CallWordBreakProc(ME_TextEditor *editor, ME_String *str, INT start, INT code) DECLSPEC_HIDDEN;
 void ME_StrDeleteV(ME_String *s, int nVChar, int nChars) DECLSPEC_HIDDEN;
diff --git a/dlls/riched20/run.c b/dlls/riched20/run.c
index 384baaa..ccee185 100644
--- a/dlls/riched20/run.c
+++ b/dlls/riched20/run.c
@@ -394,6 +394,17 @@ static BOOL run_is_splittable( const ME_Run *run )
     return FALSE;
 }
 
+static BOOL run_is_entirely_ws( const ME_Run *run )
+{
+    WCHAR *str = get_text( run, 0 ), *p;
+    int i, len = run->strText->nLen;
+
+    for (i = 0, p = str; i < len; i++, p++)
+        if (!ME_IsWSpace( *p )) return FALSE;
+
+    return TRUE;
+}
+
 /******************************************************************************
  * ME_UpdateRunFlags
  *
@@ -416,8 +427,9 @@ void ME_UpdateRunFlags(ME_TextEditor *editor, ME_Run *run)
   else
     run->nFlags &= ~MERF_SPLITTABLE;
 
-  if (!(run->nFlags & MERF_NOTEXT)) {
-    if (ME_IsWhitespaces(strText))
+  if (!(run->nFlags & MERF_NOTEXT))
+  {
+    if (run_is_entirely_ws( run ))
       run->nFlags |= MERF_WHITESPACE | MERF_STARTWHITE | MERF_ENDWHITE;
     else
     {
diff --git a/dlls/riched20/string.c b/dlls/riched20/string.c
index 02f1480..87dcb67 100644
--- a/dlls/riched20/string.c
+++ b/dlls/riched20/string.c
@@ -108,19 +108,6 @@ ME_String *ME_VSplitString(ME_String *orig, int charidx)
   return s;
 }
 
-int ME_IsWhitespaces(const ME_String *s)
-{
-  /* FIXME multibyte */
-  WCHAR *pos = s->szData;
-  while(ME_IsWSpace(*pos++))
-    ;
-  pos--;
-  if (*pos)
-    return 0;
-  else
-    return 1;
-}
-
 void ME_StrDeleteV(ME_String *s, int nVChar, int nChars)
 {
   int end_ofs = nVChar + nChars;




More information about the wine-cvs mailing list