[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 WINAPI
CharPrevA(LPCSTR start, LPCSTR ptr) CharPrevA(LPCSTR start, LPCSTR ptr)
{ {
while (*start && (start < ptr)) if (ptr > start)
{ {
LPCSTR next = CharNextA(start); --ptr;
if (next >= ptr) break; if (gpsi->dwSRVIFlags & SRVINFO_DBCSENABLED)
start = next; {
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 WINAPI
CharPrevExA(WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags) CharPrevExA(WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags)
{ {
while (*start && (start < ptr)) if (ptr > start)
{ {
LPCSTR next = CharNextExA(codepage, start, flags); LPCSTR ch;
if (next >= ptr) break; BOOL dbl = FALSE;
start = next;
--ptr;
for (ch = ptr - 1; ch >= start; --ch)
{
if (!IsDBCSLeadByteEx(codepage, *ch))
break;
dbl = !dbl;
}
if (dbl) --ptr;
} }
return (LPSTR)start; return (LPSTR)ptr;
} }
/* /*