[USER32] Rewrite CharPrev(Ex)A functions and fix tests (#4860)

Fixes 48 failing tests of user32:CharFuncs.
Only 12 minor failing tests are left!

Thanks to Simone Mario Lombardo for the problem analysis!

CORE-18415 CORE-18452
This commit is contained in:
Stanislav Motylkov 2022-11-08 00:42:26 +03:00
parent 6b53f6d824
commit 51f78918da
No known key found for this signature in database
GPG key ID: AFE513258CBA9E92

View file

@ -148,13 +148,25 @@ LPSTR
WINAPI
CharPrevA(LPCSTR start, LPCSTR ptr)
{
while (*start && (start < ptr))
if (ptr > start)
{
LPCSTR next = CharNextA(start);
if (next >= ptr) break;
start = next;
--ptr;
if (gpsi->dwSRVIFlags & SRVINFO_DBCSENABLED)
{
LPCSTR ch;
BOOL dbl = FALSE;
for (ch = ptr - 1; ch >= start; --ch)
{
if (!IsDBCSLeadByte(*ch))
break;
dbl = !dbl;
}
if (dbl) --ptr;
}
}
return (LPSTR)start;
return (LPSTR)ptr;
}
/*
@ -164,13 +176,22 @@ LPSTR
WINAPI
CharPrevExA(WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags)
{
while (*start && (start < ptr))
if (ptr > start)
{
LPCSTR next = CharNextExA(codepage, start, flags);
if (next >= ptr) break;
start = next;
LPCSTR ch;
BOOL dbl = FALSE;
--ptr;
for (ch = ptr - 1; ch >= start; --ch)
{
if (!IsDBCSLeadByteEx(codepage, *ch))
break;
dbl = !dbl;
}
if (dbl) --ptr;
}
return (LPSTR)start;
return (LPSTR)ptr;
}
/*