From 76cfe7dc5018ea9f8572ef0a5adce06c1c838784 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Thu, 31 Jan 2013 13:47:58 +0000 Subject: [PATCH] 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 87dd288250a..f01494cd5ab 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 384baaa787d..ccee1857699 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 02f14809ba7..87dcb6705cf 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;