[PATCH v6 0/2] MR4812: user32: Fix the number of characters processed by DrawTextExW.
Description: When flags does not include DT_CALCRECT, since len is calculated in the middle, it will be reduced to zero. Resulting in the length of the processed string that is finally returned to zero and the non-processing string length is unchanged. But some application taking the non-processing string length to zero as the loop end condition. Log: Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> Change-Id: Icc0f250f5f4faba1bee8326fc911a4fc9cd7c012 -- v6: user32: Fix the number of characters processed by DrawTextExW. user32/tests: Add tests for DrawTextExW. https://gitlab.winehq.org/wine/wine/-/merge_requests/4812
From: chenjiangyi <chenjiangyi(a)uniontech.com> Log: Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> Change-Id: I64052ba8aa8161ad83c1811d642aedbe462ef5ea --- dlls/user32/tests/text.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c index d3228eae1e0..f0c643c2f85 100644 --- a/dlls/user32/tests/text.c +++ b/dlls/user32/tests/text.c @@ -656,6 +656,30 @@ static void test_DrawTextCalcRect(void) ok(rect.top == rect2.top, "unexpected value %ld, got %ld\n", rect.top, rect2.top); ok(rect.bottom == rect2.bottom , "unexpected value %ld, got %ld\n", rect.bottom, rect2.bottom); + /* further tests for dtp */ + SelectObject(hdc, hOldFont); + ret = DeleteObject(hFont); + ok(ret, "DeleteObject error %lu\n", GetLastError()); + lf.lfHeight = 200 * 9 / 72; + hFont = CreateFontIndirectA(&lf); + ok(hFont != 0, "CreateFontIndirectA error %lu\n", GetLastError()); + hOldFont = SelectObject(hdc, hFont); + + SetRect( &rect, 0,0, 100, 25); + memset(&dtp, 0, sizeof(dtp)); + dtp.cbSize = sizeof(dtp); + textheight = DrawTextExW(hdc, textW, lstrlenW(textW), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); + todo_wine ok(dtp.uiLengthDrawn == 10, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn ); + + memset(&dtp, 0, sizeof(dtp)); + dtp.cbSize = sizeof(dtp); + textheight = DrawTextExW(hdc, (LPWSTR)L" a1b2c3", lstrlenW(L" a1b2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); + todo_wine ok(dtp.uiLengthDrawn == 7, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn ); + + memset(&dtp, 0, sizeof(dtp)); + dtp.cbSize = sizeof(dtp); + textheight = DrawTextExW(hdc, (LPWSTR)L"a 1\tb2c3", lstrlenW(L"a 1\tb2c3"), &rect, DT_EDITCONTROL | DT_NOPREFIX | DT_WORDBREAK, &dtp); + todo_wine ok(dtp.uiLengthDrawn == 8, "Unexpected uiLengthDrawn %d\n", dtp.uiLengthDrawn ); SelectObject(hdc, hOldFont); ret = DeleteObject(hFont); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4812
From: chenjiangyi <chenjiangyi(a)uniontech.com> Description: When flags does not include DT_CALCRECT, since len is calculated in the middle, it will be reduced to zero. Resulting in the length of the processed string that is finally returned to zero and the non-processing string length is unchanged. But some application taking the non-processing string length to zero as the loop end condition. Log: Signed-off-by: chenjiangyi <chenjiangyi(a)uniontech.com> Change-Id: Icc0f250f5f4faba1bee8326fc911a4fc9cd7c012 --- dlls/user32/text.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/user32/text.c b/dlls/user32/text.c index 1896627c893..8bc393e3664 100644 --- a/dlls/user32/text.c +++ b/dlls/user32/text.c @@ -1021,10 +1021,13 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count, } len -= len_seg; str += len_seg; + if (dtp) dtp->uiLengthDrawn += len_seg; + if (len) { assert ((flags & DT_EXPANDTABS) && *str == TAB); len--; str++; + if (dtp) dtp->uiLengthDrawn++; xseg += ((size.cx/tabwidth)+1)*tabwidth; if (prefix_offset != -1) { @@ -1044,15 +1047,18 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count, } } } - else if (size.cx > max_width) - max_width = size.cx; + else + { + if (dtp) dtp->uiLengthDrawn += len; + + if (size.cx > max_width) + max_width = size.cx; + } if (invert_y) y -= lh; else y += lh; - if (dtp) - dtp->uiLengthDrawn += len; } while (strPtr && !last_line); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4812
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details: The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=141889 Your paranoid android. === debian11 (32 bit report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit ar:MA report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit de report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit fr report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit he:IL report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit hi:IN report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit ja:JP report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11 (32 bit zh:CN report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11b (32 bit WoW report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8 === debian11b (64 bit WoW report) === user32: text.c:677: Test succeeded inside todo block: Unexpected uiLengthDrawn 7 text.c:682: Test succeeded inside todo block: Unexpected uiLengthDrawn 8
On Mon Jan 15 02:31:20 2024 +0000, JiangYi Chen wrote:
changed this line in [version 6 of the diff](/wine/wine/-/merge_requests/4812/diffs?diff_id=93349&start_sha=5f2edd7b05fc75a27a6fab60e79ba05f891288b6#9574ebccaf53a609da18e9205a4c71b27c69f03d_671_671) Hi,formating issues have fixed . Thank you !!
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/4812#note_57382
This merge request was closed by JiangYi Chen. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/4812
participants (3)
-
chenjiangyi -
JiangYi Chen (@meshine) -
Marvin