Module: wine Branch: master Commit: 6895ad6f9c074904316f1f8936729ef66ee474dc URL: https://gitlab.winehq.org/wine/wine/-/commit/6895ad6f9c074904316f1f8936729ef...
Author: Robert Wilhelm robert.wilhelm@gmx.net Date: Fri Jan 13 18:35:57 2023 +0100
vbscript/tests: Fix chr() tests with double-byte character sets.
There are no errors when running chr(-1) e.g. in utf-8 locale.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54003
---
dlls/vbscript/tests/api.vbs | 9 ++++++++- dlls/vbscript/tests/run.c | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/dlls/vbscript/tests/api.vbs b/dlls/vbscript/tests/api.vbs index 459d3ace33e..903593ebd60 100644 --- a/dlls/vbscript/tests/api.vbs +++ b/dlls/vbscript/tests/api.vbs @@ -150,7 +150,7 @@ Call ok(Chr("120") = "x", "Chr(""120"") = " & Chr("120")) sub testChrError on error resume next
- if isEnglishLang then + if MaxCharSize = 1 then call Err.clear() call Chr(-1) call ok(Err.number = 5, "Err.number = " & Err.number) @@ -159,6 +159,13 @@ sub testChrError call Err.clear() call Chr(256) call ok(Err.number = 5, "Err.number = " & Err.number) + else + call Err.clear() + call Chr(-1) + call ok(Err.number = 0, "Err.number = " & Err.number) + call Err.clear() + call Chr(256) + call ok(Err.number = 0, "Err.number = " & Err.number) end if
call Err.clear() diff --git a/dlls/vbscript/tests/run.c b/dlls/vbscript/tests/run.c index 022d714dea5..4158aa28197 100644 --- a/dlls/vbscript/tests/run.c +++ b/dlls/vbscript/tests/run.c @@ -147,6 +147,7 @@ DEFINE_EXPECT(OnLeaveScript); #define DISPID_GLOBAL_UNKOBJ 1026 #define DISPID_GLOBAL_THROWEXCEPTION 1027 #define DISPID_GLOBAL_ISARRAYFIXED 1028 +#define DISPID_GLOBAL_MAXCHARSIZE 1029
#define DISPID_TESTOBJ_PROPGET 2000 #define DISPID_TESTOBJ_PROPPUT 2001 @@ -158,6 +159,7 @@ DEFINE_EXPECT(OnLeaveScript); #define MAKE_VBSERROR(code) MAKE_HRESULT(SEVERITY_ERROR, FACILITY_VBS, code)
static BOOL strict_dispid_check, is_english, allow_ui; +static UINT MaxCharSize; static int first_day_of_week; static const char *test_name = "(null)"; static int test_counter; @@ -229,6 +231,7 @@ static const char *vt2a(VARIANT *v) */ static void detect_locale(void) { + CPINFOEXA cpinfo; HMODULE kernel32 = GetModuleHandleA("kernel32.dll"); LANGID (WINAPI *pGetThreadUILanguage)(void) = (void*)GetProcAddress(kernel32, "GetThreadUILanguage");
@@ -236,6 +239,9 @@ static void detect_locale(void) PRIMARYLANGID(GetUserDefaultUILanguage()) == LANG_ENGLISH && PRIMARYLANGID(GetUserDefaultLangID()) == LANG_ENGLISH);
+ GetCPInfoExA( CP_ACP, 0, &cpinfo ); + MaxCharSize = cpinfo.MaxCharSize; + GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER, (void*)&first_day_of_week, sizeof(first_day_of_week)); first_day_of_week = 1 + (first_day_of_week + 1) % 7; @@ -1142,6 +1148,7 @@ static HRESULT WINAPI Global_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD { L"reportSuccess", DISPID_GLOBAL_REPORTSUCCESS, REF_EXPECT(global_success_d) }, { L"getVT", DISPID_GLOBAL_GETVT }, { L"isEnglishLang", DISPID_GLOBAL_ISENGLANG }, + { L"MaxCharSize", DISPID_GLOBAL_MAXCHARSIZE }, { L"firstDayOfWeek", DISPID_GLOBAL_WEEKSTARTDAY }, { L"globalCallback", DISPID_GLOBAL_GLOBALCALLBACK }, { L"testObj", DISPID_GLOBAL_TESTOBJ }, @@ -1264,6 +1271,11 @@ static HRESULT WINAPI Global_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, V_BOOL(pvarRes) = is_english ? VARIANT_TRUE : VARIANT_FALSE; return S_OK;
+ case DISPID_GLOBAL_MAXCHARSIZE: + V_VT(pvarRes) = VT_I4; + V_I4(pvarRes) = MaxCharSize; + return S_OK; + case DISPID_GLOBAL_WEEKSTARTDAY: V_VT(pvarRes) = VT_I4; V_I4(pvarRes) = first_day_of_week;