From 4e3c4d6f1d4bf7085581b63f124d137769785cca Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Tue, 3 Nov 2020 23:34:33 +0100 Subject: [PATCH] wscript: Use wide-char string literals. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- programs/wscript/host.c | 12 +++--------- programs/wscript/main.c | 30 +++++++++--------------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/programs/wscript/host.c b/programs/wscript/host.c index 315b8ac7234..9541994d3b0 100644 --- a/programs/wscript/host.c +++ b/programs/wscript/host.c @@ -33,8 +33,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wscript); #define BUILDVERSION 16535 - -static const WCHAR wshNameW[] = {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0}; static const WCHAR wshVersionW[] = {'5','.','8'}; VARIANT_BOOL wshInteractive = @@ -49,10 +47,8 @@ static HRESULT to_string(VARIANT *src, BSTR *dst) VARIANT v; HRESULT hres; - static const WCHAR nullW[] = {'n','u','l','l',0}; - if(V_VT(src) == VT_NULL) { - *dst = SysAllocString(nullW); + *dst = SysAllocString(L"null"); return *dst ? S_OK : E_OUTOFMEMORY; } @@ -73,9 +69,7 @@ static void print_string(const WCHAR *string) char *buf; if(wshInteractive) { - static const WCHAR windows_script_hostW[] = - {'W','i','n','d','o','w','s',' ','S','c','r','i','p','t',' ','H','o','s','t',0}; - MessageBoxW(NULL, string, windows_script_hostW, MB_OK); + MessageBoxW(NULL, string, L"Windows Script Host", MB_OK); return; } @@ -163,7 +157,7 @@ static HRESULT WINAPI Host_get_Name(IHost *iface, BSTR *out_Name) { WINE_TRACE("(%p)\n", out_Name); - if(!(*out_Name = SysAllocString(wshNameW))) + if(!(*out_Name = SysAllocString(L"Windows Script Host"))) return E_OUTOFMEMORY; return S_OK; } diff --git a/programs/wscript/main.c b/programs/wscript/main.c index 8a8036073bd..a7005a9289c 100644 --- a/programs/wscript/main.c +++ b/programs/wscript/main.c @@ -47,9 +47,6 @@ #endif WINE_DEFAULT_DEBUG_CHANNEL(wscript); - -static const WCHAR wscriptW[] = {'W','S','c','r','i','p','t',0}; -static const WCHAR wshW[] = {'W','S','H',0}; WCHAR scriptFullName[MAX_PATH]; ITypeInfo *host_ti; @@ -86,7 +83,7 @@ static HRESULT WINAPI ActiveScriptSite_GetItemInfo(IActiveScriptSite *iface, { WINE_TRACE("(%s %x %p %p)\n", wine_dbgstr_w(pstrName), dwReturnMask, ppunkItem, ppti); - if(lstrcmpW(pstrName, wshW) && lstrcmpW(pstrName, wscriptW)) + if(lstrcmpW(pstrName, L"WSH") && lstrcmpW(pstrName, L"WScript")) return E_FAIL; if(dwReturnMask & SCRIPTINFO_ITYPEINFO) { @@ -223,9 +220,7 @@ static BOOL load_typelib(void) ITypeLib *typelib; HRESULT hres; - static const WCHAR wscript_exeW[] = {'w','s','c','r','i','p','t','.','e','x','e',0}; - - hres = LoadTypeLib(wscript_exeW, &typelib); + hres = LoadTypeLib(L"wscript.exe", &typelib); if(FAILED(hres)) return FALSE; @@ -245,9 +240,6 @@ static BOOL get_engine_clsid(const WCHAR *ext, CLSID *clsid) HKEY hkey; HRESULT hres; - static const WCHAR script_engineW[] = - {'\\','S','c','r','i','p','t','E','n','g','i','n','e',0}; - res = RegOpenKeyW(HKEY_CLASSES_ROOT, ext, &hkey); if(res != ERROR_SUCCESS) return FALSE; @@ -260,7 +252,7 @@ static BOOL get_engine_clsid(const WCHAR *ext, CLSID *clsid) WINE_TRACE("fileid is %s\n", wine_dbgstr_w(fileid)); - lstrcatW(fileid, script_engineW); + lstrcatW(fileid, L"\\ScriptEngine"); res = RegOpenKeyW(HKEY_CLASSES_ROOT, fileid, &hkey); if(res != ERROR_SUCCESS) return FALSE; @@ -319,11 +311,11 @@ static BOOL init_engine(IActiveScript *script, IActiveScriptParse *parser) if(FAILED(hres)) return FALSE; - hres = IActiveScript_AddNamedItem(script, wscriptW, SCRIPTITEM_ISVISIBLE); + hres = IActiveScript_AddNamedItem(script, L"WScript", SCRIPTITEM_ISVISIBLE); if(FAILED(hres)) return FALSE; - hres = IActiveScript_AddNamedItem(script, wshW, SCRIPTITEM_ISVISIBLE); + hres = IActiveScript_AddNamedItem(script, L"WSH", SCRIPTITEM_ISVISIBLE); if(FAILED(hres)) return FALSE; @@ -387,10 +379,6 @@ static void run_script(const WCHAR *filename, IActiveScript *script, IActiveScri static BOOL set_host_properties(const WCHAR *prop) { - static const WCHAR nologoW[] = {'n','o','l','o','g','o',0}; - static const WCHAR iactive[] = {'i',0}; - static const WCHAR batch[] = {'b',0}; - if(*prop == '/') { ++prop; if(*prop == '/') @@ -399,12 +387,12 @@ static BOOL set_host_properties(const WCHAR *prop) else ++prop; - if(wcsicmp(prop, iactive) == 0) + if(wcsicmp(prop, L"i") == 0) wshInteractive = VARIANT_TRUE; - else if(wcsicmp(prop, batch) == 0) + else if(wcsicmp(prop, L"b") == 0) wshInteractive = VARIANT_FALSE; - else if(wcsicmp(prop, nologoW) == 0) - WINE_FIXME("ignored %s switch\n", debugstr_w(nologoW)); + else if(wcsicmp(prop, L"nologo") == 0) + WINE_FIXME("ignored %s switch\n", debugstr_w(L"nologo")); else { WINE_FIXME("unsupported switch %s\n", debugstr_w(prop));