-- v2: vbscript: Handle CP_UTF8 in Chr()/Asc().
From: Nikolay Sivov nsivov@codeweavers.com
--- dlls/vbscript/global.c | 30 ++++++++++++++++++------------ dlls/vbscript/vbscript.c | 11 +++++++---- dlls/vbscript/vbscript.h | 1 + 3 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/dlls/vbscript/global.c b/dlls/vbscript/global.c index d60374f9e87..d07d46415e6 100644 --- a/dlls/vbscript/global.c +++ b/dlls/vbscript/global.c @@ -1842,10 +1842,12 @@ static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA
if(!SysStringLen(str)) hres = MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL); + else if (This->ctx->codepage == CP_UTF8) + hres = return_short(res, *str); else { unsigned char buf[2]; short val = 0; - int n = WideCharToMultiByte(CP_ACP, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL); + int n = WideCharToMultiByte(This->ctx->codepage, 0, str, 1, (char*)buf, sizeof(buf), NULL, NULL); switch(n) { case 1: val = buf[0]; @@ -1865,9 +1867,6 @@ static HRESULT Global_Asc(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA return hres; }
-/* The function supports only single-byte and double-byte character sets. It - * ignores language specified by IActiveScriptSite::GetLCID. The argument needs - * to be in range of short or unsigned short. */ static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VARIANT *res) { int cp, c, len = 0; @@ -1882,7 +1881,7 @@ static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA if(FAILED(hres)) return hres;
- cp = GetACP(); + cp = This->ctx->codepage; if(!GetCPInfo(cp, &cpi)) cpi.MaxCharSize = 1;
@@ -1892,13 +1891,20 @@ static HRESULT Global_Chr(BuiltinDisp *This, VARIANT *arg, unsigned args_cnt, VA return MAKE_VBSERROR(VBSE_ILLEGAL_FUNC_CALL); }
- if(c>>8) - buf[len++] = c>>8; - if(!len || IsDBCSLeadByteEx(cp, buf[0])) - buf[len++] = c; - if(!MultiByteToWideChar(CP_ACP, 0, buf, len, &ch, 1)) { - WARN("invalid arg %d, cp %d\n", c, cp); - return E_FAIL; + if (cp == CP_UTF8) + { + ch = c; + } + else + { + if(c>>8) + buf[len++] = c>>8; + if(!len || IsDBCSLeadByteEx(cp, buf[0])) + buf[len++] = c; + if(!MultiByteToWideChar(cp, 0, buf, len, &ch, 1)) { + WARN("invalid arg %d, cp %d\n", c, cp); + return E_FAIL; + } }
if(res) { diff --git a/dlls/vbscript/vbscript.c b/dlls/vbscript/vbscript.c index 428149d7132..b6364410931 100644 --- a/dlls/vbscript/vbscript.c +++ b/dlls/vbscript/vbscript.c @@ -555,8 +555,8 @@ static ULONG WINAPI VBScript_Release(IActiveScript *iface) static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScriptSite *pass) { VBScript *This = impl_from_IActiveScript(iface); + LCID lcid = LOCALE_USER_DEFAULT; named_item_t *item; - LCID lcid; HRESULT hres;
TRACE("(%p)->(%p)\n", This, pass); @@ -590,9 +590,12 @@ static HRESULT WINAPI VBScript_SetScriptSite(IActiveScript *iface, IActiveScript This->ctx->site = pass; IActiveScriptSite_AddRef(This->ctx->site);
- hres = IActiveScriptSite_GetLCID(This->ctx->site, &lcid); - if(hres == S_OK) - This->ctx->lcid = lcid; + IActiveScriptSite_GetLCID(This->ctx->site, &lcid); + This->ctx->lcid = IsValidLocale(lcid, 0) ? lcid : GetUserDefaultLCID(); + GetLocaleInfoW(lcid, LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, (WCHAR *)&This->ctx->codepage, + sizeof(This->ctx->codepage)/sizeof(WCHAR)); + if (!This->ctx->codepage) + This->ctx->codepage = CP_UTF8;
if(This->is_initialized) change_state(This, SCRIPTSTATE_INITIALIZED); diff --git a/dlls/vbscript/vbscript.h b/dlls/vbscript/vbscript.h index 3690fc4f0e2..8286b37bbab 100644 --- a/dlls/vbscript/vbscript.h +++ b/dlls/vbscript/vbscript.h @@ -183,6 +183,7 @@ static inline VARIANT *get_arg(DISPPARAMS *dp, DWORD i) struct _script_ctx_t { IActiveScriptSite *site; LCID lcid; + UINT codepage;
IInternetHostSecurityManager *secmgr; DWORD safeopt;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=126613
Your paranoid android.
=== debian11 (32 bit report) ===
d3d9: stateblock: Timeout visual: Timeout
d3dcompiler_43: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_46: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3dcompiler_47: asm: Timeout blob: Timeout hlsl_d3d11: Timeout hlsl_d3d9: Timeout reflection: Timeout
d3drm: d3drm: Timeout vector: Timeout
d3dx10_34: d3dx10: Timeout
d3dx10_35: d3dx10: Timeout
d3dx10_36: d3dx10: Timeout
Report validation errors: d3dx10_37:d3dx10 timeout
=== debian11 (build log) ===
WineRunWineTest.pl:error: The task timed out
This merge request was approved by Jacek Caban.