Module: wine Branch: master Commit: f25317a6086700ec5c895cab9a1c791a17d8ff01 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f25317a6086700ec5c895cab9a...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Fri Jun 13 10:01:22 2014 +0200
user32: Ensure at least one character is used in TEXT_WordBreak().
---
dlls/user32/tests/text.c | 8 ++++++++ dlls/user32/text.c | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c index 19bcd72..06705a7 100644 --- a/dlls/user32/tests/text.c +++ b/dlls/user32/tests/text.c @@ -564,6 +564,10 @@ static void test_DrawTextCalcRect(void) textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK); ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", textheight, heightcheck * 2); + SetRect(&rect, 0, 0, 1, 1); + textheight = DrawTextA(hdc, wordbreak_text, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL); + ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n", + textheight, heightcheck * 6);
SetRect(&rect, 0, 0, 1, 1); heightcheck = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT); @@ -571,6 +575,10 @@ static void test_DrawTextCalcRect(void) textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK); ok(textheight == heightcheck * 2, "Got unexpected textheight %d, expected %d.\n", textheight, heightcheck * 2); + SetRect(&rect, 0, 0, 1, 1); + textheight = DrawTextW(hdc, wordbreak_textW, -1, &rect, DT_CALCRECT | DT_WORDBREAK | DT_EDITCONTROL); + ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n", + textheight, heightcheck * 6);
SelectObject(hdc, hOldFont); ret = DeleteObject(hFont); diff --git a/dlls/user32/text.c b/dlls/user32/text.c index fdc3554..66a35d2 100644 --- a/dlls/user32/text.c +++ b/dlls/user32/text.c @@ -413,8 +413,9 @@ static void TEXT_WordBreak (HDC hdc, WCHAR *str, unsigned int max_str, DT_EDITCONTROL) { /* break the word after the last character that fits (there must be - * at least one; none is caught earlier). - */ + * at least one). */ + if (!chars_fit) + ++chars_fit; *len_str = chars_fit; *chars_used = chars_fit;