https://git.reactos.org/?p=reactos.git;a=commitdiff;h=51f78918dab21a9e10468…
commit 51f78918dab21a9e10468ac02144e30cf4bccbb2
Author: Stanislav Motylkov <x86corez(a)gmail.com>
AuthorDate: Tue Nov 8 00:42:26 2022 +0300
Commit: Stanislav Motylkov <x86corez(a)gmail.com>
CommitDate: Sun Nov 13 13:22:26 2022 +0300
[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
---
win32ss/user/user32/windows/text.c | 41 ++++++++++++++++++++++++++++----------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/win32ss/user/user32/windows/text.c b/win32ss/user/user32/windows/text.c
index bf730d749c9..1a73d674101 100644
--- a/win32ss/user/user32/windows/text.c
+++ b/win32ss/user/user32/windows/text.c
@@ -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;
}
/*