Skip to content

Commit

Permalink
mlang: Fix bug with codepage priority in GetStrCodePages.
Browse files Browse the repository at this point in the history
  • Loading branch information
tati-frog authored and julliard committed Feb 12, 2024
1 parent bc62314 commit b549ae1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions dlls/mlang/mlang.c
Original file line number Diff line number Diff line change
Expand Up @@ -3336,23 +3336,20 @@ static HRESULT WINAPI fnIMLangFontLink2_GetStrCodePages( IMLangFontLink2* iface,

for (i = 0; i < src_len; i++)
{
DWORD cp, next_cp = 0;
DWORD cp = 0;
HRESULT ret;

ret = IMLangFontLink2_GetCharCodePages(iface, src[i], &cp);
if (i + 1 < src_len)
ret = IMLangFontLink2_GetCharCodePages(iface, src[i + 1], &next_cp);
if (ret != S_OK) return E_FAIL;

if (!cps) cps = cp;
else if ((cps & cp) != 0) cps &= cp;
else if ((cps & cp) != 0 &&
!((priority_cp & cps) ^ (priority_cp & cp))) cps &= cp;
else
{
i--;
break;
}

if ((priority_cp & cps) && !(priority_cp & next_cp)) break;
}

if (codepages) *codepages = cps;
Expand Down
2 changes: 1 addition & 1 deletion dlls/mlang/tests/mlang.c
Original file line number Diff line number Diff line change
Expand Up @@ -1330,7 +1330,7 @@ static void IMLangFontLink_Test(IMLangFontLink* iMLFL)
ret = IMLangFontLink_GetStrCodePages(iMLFL, L"\uff90a", 2, FS_LATIN1, &dwCodePages, &processed);
ok(ret == S_OK, "IMLangFontLink_GetStrCodePages error %lx\n", ret);
ok(dwCodePages == dwCmpCodePages, "expected %lx, got %lx\n", dwCmpCodePages, dwCodePages);
todo_wine ok(processed == 1, "expected 1, got %ld\n", processed);
ok(processed == 1, "expected 1, got %ld\n", processed);

dwCodePages = 0xffff;
processed = -1;
Expand Down

0 comments on commit b549ae1

Please sign in to comment.