[PATCH] itss: Use wide-char string literals.

Michael Stefaniuc mstefani at winehq.org
Thu Nov 19 16:03:01 CST 2020


Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
 dlls/itss/chm_lib.c        | 33 ++++------------------
 dlls/itss/moniker.c        |  7 ++---
 dlls/itss/protocol.c       |  8 ++----
 dlls/itss/storage.c        |  3 +-
 dlls/itss/tests/protocol.c | 58 +++++++++++++-------------------------
 5 files changed, 29 insertions(+), 80 deletions(-)

diff --git a/dlls/itss/chm_lib.c b/dlls/itss/chm_lib.c
index be04ae5673a..91e3fa3d811 100644
--- a/dlls/itss/chm_lib.c
+++ b/dlls/itss/chm_lib.c
@@ -203,31 +203,6 @@ static BOOL _unmarshal_uuid(unsigned char **pData,
     return _unmarshal_uchar_array(pData, pDataLen, dest, 16);
 }
 
-/* names of sections essential to decompression */
-static const WCHAR _CHMU_RESET_TABLE[] = {
-':',':','D','a','t','a','S','p','a','c','e','/',
-        'S','t','o','r','a','g','e','/',
-        'M','S','C','o','m','p','r','e','s','s','e','d','/',
-        'T','r','a','n','s','f','o','r','m','/',
-        '{','7','F','C','2','8','9','4','0','-','9','D','3','1',
-          '-','1','1','D','0','-','9','B','2','7','-',
-          '0','0','A','0','C','9','1','E','9','C','7','C','}','/',
-        'I','n','s','t','a','n','c','e','D','a','t','a','/',
-        'R','e','s','e','t','T','a','b','l','e',0
-};
-static const WCHAR _CHMU_LZXC_CONTROLDATA[] = {
-':',':','D','a','t','a','S','p','a','c','e','/',
-        'S','t','o','r','a','g','e','/',
-        'M','S','C','o','m','p','r','e','s','s','e','d','/',
-        'C','o','n','t','r','o','l','D','a','t','a',0
-};
-static const WCHAR _CHMU_CONTENT[] = {
-':',':','D','a','t','a','S','p','a','c','e','/',
-        'S','t','o','r','a','g','e','/',
-        'M','S','C','o','m','p','r','e','s','s','e','d','/',
-        'C','o','n','t','e','n','t',0
-};
-
 /*
  * structures local to this module
  */
@@ -766,15 +741,17 @@ struct chmFile *chm_openW(const WCHAR *filename)
 
     /* prefetch most commonly needed unit infos */
     if (CHM_RESOLVE_SUCCESS != chm_resolve_object(newHandle,
-                                                  _CHMU_RESET_TABLE,
+                                                  L"::DataSpace/Storage/MSCompressed/Transform/"
+                                                  "{7FC28940-9D31-11D0-9B27-00A0C91E9C7C}/"
+                                                  "InstanceData/ResetTable",
                                                   &newHandle->rt_unit)    ||
         newHandle->rt_unit.space == CHM_COMPRESSED                        ||
         CHM_RESOLVE_SUCCESS != chm_resolve_object(newHandle,
-                                                  _CHMU_CONTENT,
+                                                  L"::DataSpace/Storage/MSCompressed/Content",
                                                   &newHandle->cn_unit)    ||
         newHandle->cn_unit.space == CHM_COMPRESSED                        ||
         CHM_RESOLVE_SUCCESS != chm_resolve_object(newHandle,
-                                                  _CHMU_LZXC_CONTROLDATA,
+                                                  L"::DataSpace/Storage/MSCompressed/ControlData",
                                                   &uiLzxc)                ||
         uiLzxc.space == CHM_COMPRESSED)
     {
diff --git a/dlls/itss/moniker.c b/dlls/itss/moniker.c
index 41faa23fb5e..3d0063f2bb7 100644
--- a/dlls/itss/moniker.c
+++ b/dlls/itss/moniker.c
@@ -283,8 +283,6 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName(
     LPOLESTR* ppszDisplayName)
 {
     ITS_IMonikerImpl *This = impl_from_IMoniker(iface);
-    static const WCHAR szFormat[] = {
-        'm','s','-','i','t','s',':','%','s',':',':','%','s',0 };
     DWORD len;
     LPWSTR str;
 
@@ -292,7 +290,7 @@ static HRESULT WINAPI ITS_IMonikerImpl_GetDisplayName(
 
     len = lstrlenW( This->szFile ) + lstrlenW( This->szHtml );
     str = CoTaskMemAlloc( len*sizeof(WCHAR) );
-    swprintf( str, len, szFormat, This->szFile, This->szHtml );
+    swprintf( str, len, L"ms-its:%s::%s", This->szFile, This->szHtml );
 
     *ppszDisplayName = str;
     
@@ -431,8 +429,7 @@ static HRESULT WINAPI ITS_IParseDisplayNameImpl_ParseDisplayName(
     ULONG * pchEaten,
     IMoniker ** ppmkOut)
 {
-    static const WCHAR szPrefix[] = { 
-        '@','M','S','I','T','S','t','o','r','e',':',0 };
+    static const WCHAR szPrefix[] = L"@MSITStore:";
     const DWORD prefix_len = ARRAY_SIZE(szPrefix)-1;
     DWORD n;
 
diff --git a/dlls/itss/protocol.c b/dlls/itss/protocol.c
index 3f5362e5b9b..167ce906b90 100644
--- a/dlls/itss/protocol.c
+++ b/dlls/itss/protocol.c
@@ -231,8 +231,6 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
     int res;
     HRESULT hres;
 
-    static const WCHAR separator[] = {':',':',0};
-
     TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
             pOIBindInfo, grfPI, dwReserved);
 
@@ -260,7 +258,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
         return hres;
     }
 
-    p = wcsstr(file_name, separator);
+    p = wcsstr(file_name, L"::");
     if(!p) {
         WARN("invalid url\n");
         HeapFree(GetProcessHeap(), 0, file_name);
@@ -480,13 +478,11 @@ static HRESULT WINAPI ITSProtocolInfo_CombineUrl(IInternetProtocolInfo *iface,
     LPCWSTR base_end, ptr;
     DWORD rel_len;
 
-    static const WCHAR separator[] = {':',':',0};
-
     TRACE("(%p)->(%s %s %08x %p %d %p %d)\n", This, debugstr_w(pwzBaseUrl),
             debugstr_w(pwzRelativeUrl), dwCombineFlags, pwzResult, cchResult,
             pcchResult, dwReserved);
 
-    base_end = wcsstr(pwzBaseUrl, separator);
+    base_end = wcsstr(pwzBaseUrl, L"::");
     if(!base_end)
         return 0x80041001;
     base_end += 2;
diff --git a/dlls/itss/storage.c b/dlls/itss/storage.c
index 86d33f29dfb..ee5432d4d61 100644
--- a/dlls/itss/storage.c
+++ b/dlls/itss/storage.c
@@ -639,7 +639,6 @@ HRESULT ITSS_StgOpenStorage(
     IStorage** ppstgOpen)
 {
     struct chmFile *chmfile;
-    static const WCHAR szRoot[] = { '/', 0 };
 
     TRACE("%s\n", debugstr_w(pwcsName) );
 
@@ -647,7 +646,7 @@ HRESULT ITSS_StgOpenStorage(
     if( !chmfile )
         return E_FAIL;
 
-    return ITSS_create_chm_storage( chmfile, szRoot, ppstgOpen );
+    return ITSS_create_chm_storage( chmfile, L"/", ppstgOpen );
 }
 
 /************************************************************************/
diff --git a/dlls/itss/tests/protocol.c b/dlls/itss/tests/protocol.c
index 4cafba7b615..43d867b9cfb 100644
--- a/dlls/itss/tests/protocol.c
+++ b/dlls/itss/tests/protocol.c
@@ -66,36 +66,24 @@ static HRESULT expect_hrResult;
 static IInternetProtocol *read_protocol = NULL;
 static DWORD bindf;
 
-static const WCHAR blank_url1[] = {'i','t','s',':',
-    't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url2[] = {'m','S','-','i','T','s',':',
-    't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url3[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
-    't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url4[] = {'i','t','s',':',
-    't','e','s','t','.','c','h','m',':',':','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url5[] = {'i','t','s',':',
-    't','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url6[] = {'i','t','s',':',
-    't','e','s','t','.','c','h','m',':',':','/','%','6','2','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url7[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
-    't','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR blank_url8[] = {'m','k',':','@','M','S','I','T','S','t','o','r','e',':',
-    't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l','/',0};
-static const WCHAR blank_url9[] = {'i','t','s',':',
-    't','e','s','t','.','c','h','m',':',':','/','d','i','r','/','.','.','/','b','l','a','n','k','.','h','t','m','l',0};
+static const WCHAR blank_url1[] = L"its:test.chm::/blank.html";
+static const WCHAR blank_url2[] = L"mS-iTs:test.chm::/blank.html";
+static const WCHAR blank_url3[] = L"mk:@MSITStore:test.chm::/blank.html";
+static const WCHAR blank_url4[] = L"its:test.chm::blank.html";
+static const WCHAR blank_url5[] = L"its:test.chm::\\blank.html";
+static const WCHAR blank_url6[] = L"its:test.chm::/%62lank.html";
+static const WCHAR blank_url7[] = L"mk:@MSITStore:test.chm::\\blank.html";
+static const WCHAR blank_url8[] = L"mk:@MSITStore:test.chm::/blank.html/";
+static const WCHAR blank_url9[] = L"its:test.chm::/dir/../blank.html";
 
 static enum {
     ITS_PROTOCOL,
     MK_PROTOCOL
 } test_protocol;
 
-static const WCHAR cache_file1[] =
-    {'t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR cache_file2[] =
-    {'t','e','s','t','.','c','h','m',':',':','\\','b','l','a','n','k','.','h','t','m','l',0};
-static const WCHAR cache_file3[] =
-    {'t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l','/',0};
+static const WCHAR cache_file1[] = L"test.chm::/blank.html";
+static const WCHAR cache_file2[] = L"test.chm::\\blank.html";
+static const WCHAR cache_file3[] = L"test.chm::/blank.html/";
 static const WCHAR *cache_file = cache_file1;
 
 static HRESULT WINAPI ProtocolSink_QueryInterface(IInternetProtocolSink *iface, REFIID riid, void **ppv)
@@ -126,9 +114,6 @@ static HRESULT WINAPI ProtocolSink_Switch(IInternetProtocolSink *iface, PROTOCOL
 static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface, ULONG ulStatusCode,
         LPCWSTR szStatusText)
 {
-    static const WCHAR blank_html[] = {'b','l','a','n','k','.','h','t','m','l',0};
-    static const WCHAR text_html[] = {'t','e','x','t','/','h','t','m','l',0};
-
     switch(ulStatusCode) {
     case BINDSTATUS_BEGINDOWNLOADDATA:
         CHECK_EXPECT(ReportProgress_BEGINDOWNLOADDATA);
@@ -137,13 +122,13 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
     case BINDSTATUS_SENDINGREQUEST:
         CHECK_EXPECT(ReportProgress_SENDINGREQUEST);
         if(test_protocol == ITS_PROTOCOL)
-            ok(!lstrcmpW(szStatusText, blank_html), "unexpected szStatusText\n");
+            ok(!lstrcmpW(szStatusText, L"blank.html"), "unexpected szStatusText\n");
         else
             ok(szStatusText == NULL, "szStatusText != NULL\n");
         break;
     case BINDSTATUS_MIMETYPEAVAILABLE:
         CHECK_EXPECT(ReportProgress_MIMETYPEAVAILABLE);
-        ok(!lstrcmpW(szStatusText, text_html), "unexpected szStatusText\n");
+        ok(!lstrcmpW(szStatusText, L"text/html"), "unexpected szStatusText\n");
         break;
     case BINDSTATUS_CACHEFILENAMEAVAILABLE:
         CHECK_EXPECT(ReportProgress_CACHEFILENAMEAVAILABLE);
@@ -523,16 +508,11 @@ static void test_its_protocol(void)
     ULONG ref;
     HRESULT hres;
 
-    static const WCHAR wrong_url1[] =
-        {'i','t','s',':','t','e','s','t','.','c','h','m',':',':','/','b','l','a','n','.','h','t','m','l',0};
-    static const WCHAR wrong_url2[] =
-        {'i','t','s',':','t','e','s','.','c','h','m',':',':','b','/','l','a','n','k','.','h','t','m','l',0};
-    static const WCHAR wrong_url3[] =
-        {'i','t','s',':','t','e','s','t','.','c','h','m','/','b','l','a','n','k','.','h','t','m','l',0};
-    static const WCHAR wrong_url4[] = {'m','k',':','@','M','S','I','T','S','t','o','r',':',
-         't','e','s','t','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
-    static const WCHAR wrong_url5[] = {'f','i','l','e',':',
-        't','e','s','.','c','h','m',':',':','/','b','l','a','n','k','.','h','t','m','l',0};
+    static const WCHAR wrong_url1[] = L"its:test.chm::/blan.html";
+    static const WCHAR wrong_url2[] = L"its:tes.chm::b/lank.html";
+    static const WCHAR wrong_url3[] = L"its:test.chm/blank.html";
+    static const WCHAR wrong_url4[] = L"mk:@MSITStor:test.chm::/blank.html";
+    static const WCHAR wrong_url5[] = L"file:tes.chm::/blank.html";
 
     test_protocol = ITS_PROTOCOL;
 
-- 
2.26.2




More information about the wine-devel mailing list