From 568c32f381f71754b523d57a328684862bd44e6a Mon Sep 17 00:00:00 2001 From: Michael Stefaniuc Date: Wed, 7 Oct 2020 00:51:58 +0200 Subject: [PATCH] atl: Use wide-char string literals. Signed-off-by: Michael Stefaniuc Signed-off-by: Alexandre Julliard --- dlls/atl/atl.c | 20 +++++--------- dlls/atl/atl_ax.c | 35 +++++++++++------------- dlls/atl/registrar.c | 60 +++++++++++++++-------------------------- dlls/atl/tests/atl_ax.c | 3 +-- 4 files changed, 44 insertions(+), 74 deletions(-) diff --git a/dlls/atl/atl.c b/dlls/atl/atl.c index 358986d7a4c..7529425b7ee 100644 --- a/dlls/atl/atl.c +++ b/dlls/atl/atl.c @@ -123,7 +123,6 @@ HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk) */ HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv ) { - static const WCHAR displayW[] = {'d','i','s','p','l','a','y',0}; const WCHAR *driver = NULL, *device = NULL, *port = NULL; DEVMODEW *devmode = NULL; @@ -139,7 +138,7 @@ HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv ) else { if (hdc) return hdc; - driver = displayW; + driver = L"display"; } return CreateDCW( driver, device, port, devmode ); } @@ -342,12 +341,10 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, WCHAR *path; HRESULT hres; - static const WCHAR tlb_extW[] = {'.','t','l','b',0}; - TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib); index_len = lpszIndex ? lstrlenW(lpszIndex) : 0; - path = heap_alloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(tlb_extW)); + path = heap_alloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb")); if(!path) return E_OUTOFMEMORY; @@ -367,7 +364,7 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, for(ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--); if(*ptr != '.') ptr = path+path_len; - memcpy(ptr, tlb_extW, sizeof(tlb_extW)); + lstrcpyW(ptr, L".tlb"); hres = LoadTypeLib(path, &typelib); } @@ -781,20 +778,15 @@ HRESULT WINAPI AtlRegisterClassCategoriesHelper(REFCLSID clsid, const struct _AT } if(!reg) { - WCHAR reg_path[256] = {'C','L','S','I','D','\\'}, *ptr = reg_path+6; - - static const WCHAR implemented_catW[] = - {'I','m','p','l','e','m','e','n','t','e','d',' ','C','a','t','e','g','o','r','i','e','s',0}; - static const WCHAR required_catW[] = - {'R','e','q','u','i','r','e','d',' ','C','a','t','e','g','o','r','i','e','s',0}; + WCHAR reg_path[256] = L"CLSID\\", *ptr = reg_path+6; ptr += StringFromGUID2(clsid, ptr, 64)-1; *ptr++ = '\\'; - memcpy(ptr, implemented_catW, sizeof(implemented_catW)); + lstrcpyW(ptr, L"Implemented Categories"); RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path); - memcpy(ptr, required_catW, sizeof(required_catW)); + lstrcpyW(ptr, L"Required Categories"); RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path); } diff --git a/dlls/atl/atl_ax.c b/dlls/atl/atl_ax.c index 3bb9dbc22df..69d42f55813 100644 --- a/dlls/atl/atl_ax.c +++ b/dlls/atl/atl_ax.c @@ -55,8 +55,6 @@ typedef struct IOCS { BOOL fActive, fInPlace, fWindowless; } IOCS; -static const WCHAR wine_atl_iocsW[] = {'_','_','W','I','N','E','_','A','T','L','_','I','O','C','S','\0'}; - /********************************************************************** * AtlAxWin class window procedure */ @@ -90,20 +88,20 @@ BOOL WINAPI AtlAxWinInit(void) WNDCLASSEXW wcex; #if _ATL_VER <= _ATL_VER_30 -#define ATL_NAME_SUFFIX 0 +#define ATL_NAME_SUFFIX #elif _ATL_VER == _ATL_VER_80 -#define ATL_NAME_SUFFIX '8','0',0 +#define ATL_NAME_SUFFIX L"80" #elif _ATL_VER == _ATL_VER_90 -#define ATL_NAME_SUFFIX '9','0',0 +#define ATL_NAME_SUFFIX L"90" #elif _ATL_VER == _ATL_VER_100 -#define ATL_NAME_SUFFIX '1','0','0',0 +#define ATL_NAME_SUFFIX L"100" #elif _ATL_VER == _ATL_VER_110 -#define ATL_NAME_SUFFIX '1','1','0',0 +#define ATL_NAME_SUFFIX L"110" #else #error Unsupported version #endif - static const WCHAR AtlAxWinW[] = {'A','t','l','A','x','W','i','n',ATL_NAME_SUFFIX}; + static const WCHAR AtlAxWinW[] = L"AtlAxWin" ATL_NAME_SUFFIX; FIXME("version %04x semi-stub\n", _ATL_VER); @@ -127,7 +125,7 @@ BOOL WINAPI AtlAxWinInit(void) return FALSE; if(_ATL_VER > _ATL_VER_30) { - static const WCHAR AtlAxWinLicW[] = {'A','t','l','A','x','W','i','n','L','i','c',ATL_NAME_SUFFIX}; + static const WCHAR AtlAxWinLicW[] = L"AtlAxWinLic" ATL_NAME_SUFFIX; wcex.lpszClassName = AtlAxWinLicW; if ( !RegisterClassExW( &wcex ) ) @@ -152,7 +150,7 @@ static HRESULT IOCS_Detach( IOCS *This ) /* remove subclassing */ if ( This->hWnd ) { SetWindowLongPtrW( This->hWnd, GWLP_WNDPROC, (ULONG_PTR) This->OrigWndProc ); - RemovePropW( This->hWnd, wine_atl_iocsW); + RemovePropW( This->hWnd, L"__WINE_ATL_IOCS" ); This->hWnd = NULL; } if ( This->control ) @@ -906,7 +904,7 @@ static LRESULT IOCS_OnWndProc( IOCS *This, HWND hWnd, UINT uMsg, WPARAM wParam, static LRESULT CALLBACK AtlHost_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam ) { - IOCS *This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); + IOCS *This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" ); return IOCS_OnWndProc( This, hWnd, wMsg, wParam, lParam ); } @@ -915,7 +913,7 @@ static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* su This->hWnd = hWnd; IUnknown_QueryInterface( pUnkControl, &IID_IOleObject, (void**)&This->control ); IOleObject_SetClientSite( This->control, &This->IOleClientSite_iface ); - SetPropW( hWnd, wine_atl_iocsW, This ); + SetPropW( hWnd, L"__WINE_ATL_IOCS", This ); This->OrigWndProc = (WNDPROC)SetWindowLongPtrW( hWnd, GWLP_WNDPROC, (ULONG_PTR) AtlHost_wndproc ); return S_OK; @@ -924,9 +922,8 @@ static HRESULT IOCS_Attach( IOCS *This, HWND hWnd, IUnknown *pUnkControl ) /* su static HRESULT IOCS_Init( IOCS *This ) { RECT rect; - static const WCHAR AXWIN[] = {'A','X','W','I','N',0}; - IOleObject_SetHostNames( This->control, AXWIN, AXWIN ); + IOleObject_SetHostNames( This->control, L"AXWIN", L"AXWIN" ); GetClientRect( This->hWnd, &rect ); IOCS_OnSize( This, &rect ); @@ -1000,7 +997,6 @@ enum content static enum content get_content_type(LPCOLESTR name, CLSID *control_id) { - static const WCHAR mshtml_prefixW[] = {'m','s','h','t','m','l',':',0}; WCHAR new_urlW[MAX_PATH]; DWORD size = MAX_PATH; @@ -1021,7 +1017,7 @@ static enum content get_content_type(LPCOLESTR name, CLSID *control_id) return IsURL; } - if (!wcsnicmp(name, mshtml_prefixW, 7)) + if (!wcsnicmp(name, L"mshtml:", 7)) { FIXME("mshtml prefix not implemented\n"); *control_id = CLSID_WebBrowser; @@ -1266,8 +1262,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl) src += lstrlenW(src) + 1; /* title */ if ( GET_WORD(tmp) == '{' ) /* all this mess created because of this line */ { - static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n', 0}; - PUT_BLOCK(AtlAxWin, ARRAY_SIZE(AtlAxWin)); + PUT_BLOCK(L"AtlAxWin", ARRAY_SIZE(L"AtlAxWin")); PUT_BLOCK(tmp, lstrlenW(tmp)+1); } else PUT_BLOCK(tmp, src-tmp); @@ -1373,7 +1368,7 @@ HRESULT WINAPI AtlAxGetHost(HWND hWnd, IUnknown **host) *host = NULL; - This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); + This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" ); if ( !This ) { WARN("No container attached to %p\n", hWnd ); @@ -1395,7 +1390,7 @@ HRESULT WINAPI AtlAxGetControl(HWND hWnd, IUnknown **pUnk) *pUnk = NULL; - This = (IOCS*) GetPropW( hWnd, wine_atl_iocsW ); + This = (IOCS*) GetPropW( hWnd, L"__WINE_ATL_IOCS" ); if ( !This || !This->control ) { WARN("No control attached to %p\n", hWnd ); diff --git a/dlls/atl/registrar.c b/dlls/atl/registrar.c index 586cce3201d..7c3c5976b22 100644 --- a/dlls/atl/registrar.c +++ b/dlls/atl/registrar.c @@ -32,27 +32,20 @@ static const struct { WCHAR name[22]; HKEY key; } root_keys[] = { - {{'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0}, - HKEY_CLASSES_ROOT}, - {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0}, - HKEY_CURRENT_USER}, - {{'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0}, - HKEY_LOCAL_MACHINE}, - {{'H','K','E','Y','_','U','S','E','R','S',0}, - HKEY_USERS}, - {{'H','K','E','Y','_','P','E','R','F','O','R','M','A','N','C','E','_','D','A','T','A',0}, - HKEY_PERFORMANCE_DATA}, - {{'H','K','E','Y','_','D','Y','N','_','D','A','T','A',0}, - HKEY_DYN_DATA}, - {{'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0}, - HKEY_CURRENT_CONFIG}, - {{'H','K','C','R',0}, HKEY_CLASSES_ROOT}, - {{'H','K','C','U',0}, HKEY_CURRENT_USER}, - {{'H','K','L','M',0}, HKEY_LOCAL_MACHINE}, - {{'H','K','U',0}, HKEY_USERS}, - {{'H','K','P','D',0}, HKEY_PERFORMANCE_DATA}, - {{'H','K','D','D',0}, HKEY_DYN_DATA}, - {{'H','K','C','C',0}, HKEY_CURRENT_CONFIG} + {L"HKEY_CLASSES_ROOT", HKEY_CLASSES_ROOT}, + {L"HKEY_CURRENT_USER", HKEY_CURRENT_USER}, + {L"HKEY_LOCAL_MACHINE", HKEY_LOCAL_MACHINE}, + {L"HKEY_USERS", HKEY_USERS}, + {L"HKEY_PERFORMANCE_DATA", HKEY_PERFORMANCE_DATA}, + {L"HKEY_DYN_DATA", HKEY_DYN_DATA}, + {L"HKEY_CURRENT_CONFIG", HKEY_CURRENT_CONFIG}, + {L"HKCR", HKEY_CLASSES_ROOT}, + {L"HKCU", HKEY_CURRENT_USER}, + {L"HKLM", HKEY_LOCAL_MACHINE}, + {L"HKU", HKEY_USERS}, + {L"HKPD", HKEY_PERFORMANCE_DATA}, + {L"HKDD", HKEY_DYN_DATA}, + {L"HKCC", HKEY_CURRENT_CONFIG} }; typedef struct rep_list_str { @@ -150,7 +143,6 @@ static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf) { LPCOLESTR iter, iter2 = data; rep_list *rep_iter; - static const WCHAR wstr[] = {'%',0}; iter = wcschr(data, '%'); while(iter) { @@ -164,7 +156,7 @@ static HRESULT do_preprocess(const Registrar *This, LPCOLESTR data, strbuf *buf) return DISP_E_EXCEPTION; if(iter == iter2) { - strbuf_write(wstr, buf, 1); + strbuf_write(L"%", buf, 1); }else { for(rep_iter = This->rep; rep_iter; rep_iter = rep_iter->next) { if(rep_iter->key_len == iter-iter2 @@ -205,11 +197,6 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO DO_DELETE } key_type = NORMAL; - static const WCHAR wstrNoRemove[] = {'N','o','R','e','m','o','v','e',0}; - static const WCHAR wstrForceRemove[] = {'F','o','r','c','e','R','e','m','o','v','e',0}; - static const WCHAR wstrDelete[] = {'D','e','l','e','t','e',0}; - static const WCHAR wstrval[] = {'v','a','l',0}; - iter = *pstr; hres = get_word(&iter, buf); if(FAILED(hres)) @@ -218,13 +205,13 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO while(buf->str[1] || buf->str[0] != '}') { key_type = NORMAL; - if(!lstrcmpiW(buf->str, wstrNoRemove)) + if(!lstrcmpiW(buf->str, L"NoRemove")) key_type = NO_REMOVE; - else if(!lstrcmpiW(buf->str, wstrForceRemove)) + else if(!lstrcmpiW(buf->str, L"ForceRemove")) key_type = FORCE_REMOVE; - else if(!lstrcmpiW(buf->str, wstrval)) + else if(!lstrcmpiW(buf->str, L"val")) key_type = IS_VAL; - else if(!lstrcmpiW(buf->str, wstrDelete)) + else if(!lstrcmpiW(buf->str, L"Delete")) key_type = DO_DELETE; if(key_type != NORMAL) { @@ -716,9 +703,6 @@ HRESULT WINAPI AtlUpdateRegistryFromResourceD(HINSTANCE inst, LPCOLESTR res, IRegistrar *registrar; HRESULT hres; - static const WCHAR moduleW[] = {'M','O','D','U','L','E',0}; - static const WCHAR registryW[] = {'R','E','G','I','S','T','R','Y',0}; - if(!GetModuleFileNameW(inst, module_name, MAX_PATH)) { FIXME("hinst %p: did not get module name\n", inst); return E_FAIL; @@ -735,15 +719,15 @@ HRESULT WINAPI AtlUpdateRegistryFromResourceD(HINSTANCE inst, LPCOLESTR res, return hres; } - IRegistrar_AddReplacement(registrar, moduleW, module_name); + IRegistrar_AddReplacement(registrar, L"MODULE", module_name); for (iter = pMapEntries; iter && iter->szKey; iter++) IRegistrar_AddReplacement(registrar, iter->szKey, iter->szData); if(bRegister) - hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, registryW); + hres = IRegistrar_ResourceRegisterSz(registrar, module_name, res, L"REGISTRY"); else - hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, registryW); + hres = IRegistrar_ResourceUnregisterSz(registrar, module_name, res, L"REGISTRY"); if(registrar != pReg) IRegistrar_Release(registrar); diff --git a/dlls/atl/tests/atl_ax.c b/dlls/atl/tests/atl_ax.c index 6b944d1b285..94db3640ee3 100644 --- a/dlls/atl/tests/atl_ax.c +++ b/dlls/atl/tests/atl_ax.c @@ -115,7 +115,6 @@ static void test_ax_win(void) { BOOL ret; WNDCLASSEXW wcex; - static const WCHAR AtlAxWin[] = {'A','t','l','A','x','W','i','n',0}; static HMODULE hinstance = 0; ret = AtlAxWinInit(); @@ -124,7 +123,7 @@ static void test_ax_win(void) hinstance = GetModuleHandleA(NULL); memset(&wcex, 0, sizeof(wcex)); wcex.cbSize = sizeof(wcex); - ret = GetClassInfoExW(hinstance, AtlAxWin, &wcex); + ret = GetClassInfoExW(hinstance, L"AtlAxWin", &wcex); ok(ret, "AtlAxWin has not registered\n"); ok(wcex.style == CS_GLOBALCLASS, "wcex.style %08x\n", wcex.style); }