Michael Stefaniuc : ole32: Use wide-char string literals in filemoniker.c.
Alexandre Julliard
julliard at winehq.org
Fri Nov 27 16:04:37 CST 2020
Module: wine
Branch: master
Commit: 496c6734e4d89104ab189b38ad6cbb81c6fdec71
URL: https://source.winehq.org/git/wine.git/?a=commit;h=496c6734e4d89104ab189b38ad6cbb81c6fdec71
Author: Michael Stefaniuc <mstefani at winehq.org>
Date: Fri Nov 27 09:00:22 2020 +0000
ole32: Use wide-char string literals in filemoniker.c.
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ole32/filemoniker.c | 45 +++++++++++++++++++--------------------------
1 file changed, 19 insertions(+), 26 deletions(-)
diff --git a/dlls/ole32/filemoniker.c b/dlls/ole32/filemoniker.c
index e5978169ca1..d8c401c8978 100644
--- a/dlls/ole32/filemoniker.c
+++ b/dlls/ole32/filemoniker.c
@@ -657,8 +657,6 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
{
HRESULT res;
LPOLESTR str1=0,str2=0,*strDec1=0,*strDec2=0,newStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
IBindCtx *bind=0;
int i=0,j=0,lastIdx1=0,lastIdx2=0;
DWORD mkSys, order;
@@ -687,17 +685,15 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
lastIdx1=FileMonikerImpl_DecomposePath(str1,&strDec1)-1;
lastIdx2=FileMonikerImpl_DecomposePath(str2,&strDec2)-1;
- if ((lastIdx1==-1 && lastIdx2>-1)||(lastIdx1==1 && wcscmp(strDec1[0],twoPoint)==0))
+ if ((lastIdx1 == -1 && lastIdx2 > -1) || (lastIdx1 == 1 && !wcscmp(strDec1[0], L"..")))
res = MK_E_SYNTAX;
else{
- if(wcscmp(strDec1[lastIdx1],bkSlash)==0)
+ if (!wcscmp(strDec1[lastIdx1], L"\\"))
lastIdx1--;
/* for each "..\" in the left of str2 remove the right element from str1 */
- for(i=0; ( (lastIdx1>=0) && (strDec2[i]!=NULL) && (wcscmp(strDec2[i],twoPoint)==0) ); i+=2){
-
+ for (i = 0; lastIdx1 >= 0 && strDec2[i] && !wcscmp(strDec2[i], L".."); i += 2)
lastIdx1-=2;
- }
/* the length of the composed path string is increased by the sum of the two paths' lengths */
newStr=HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(lstrlenW(str1)+lstrlenW(str2)+1));
@@ -707,8 +703,8 @@ FileMonikerImpl_ComposeWith(IMoniker* iface, IMoniker* pmkRight,
for(*newStr=0,j=0;j<=lastIdx1;j++)
lstrcatW(newStr,strDec1[j]);
- if ((strDec2[i]==NULL && lastIdx1>-1 && lastIdx2>-1) || wcscmp(strDec2[i],bkSlash)!=0)
- lstrcatW(newStr,bkSlash);
+ if ((!strDec2[i] && lastIdx1 > -1 && lastIdx2 > -1) || wcscmp(strDec2[i], L"\\"))
+ lstrcatW(newStr, L"\\");
for(j=i;j<=lastIdx2;j++)
lstrcatW(newStr,strDec2[j]);
@@ -1016,7 +1012,6 @@ failed:
*/
int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
{
- static const WCHAR bSlash[] = {'\\',0};
LPOLESTR word;
int i=0,j,tabIndex=0, ret=0;
LPOLESTR *strgtable ;
@@ -1040,7 +1035,8 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
while(str[i]!=0){
- if(str[i]==bSlash[0]){
+ if (str[i] == L'\\')
+ {
strgtable[tabIndex]=CoTaskMemAlloc(2*sizeof(WCHAR));
@@ -1050,14 +1046,14 @@ int FileMonikerImpl_DecomposePath(LPCOLESTR str, LPOLESTR** stringTable)
goto lend;
}
- lstrcpyW(strgtable[tabIndex++],bSlash);
+ lstrcpyW(strgtable[tabIndex++], L"\\");
i++;
}
else {
- for(j=0; str[i]!=0 && str[i]!=bSlash[0] ; i++,j++)
+ for (j = 0; str[i] && str[i] != L'\\'; i++, j++)
word[j]=str[i];
word[j]=0;
@@ -1103,7 +1099,6 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
HRESULT res;
LPOLESTR str1=0,str2=0,*tabStr1=0,*tabStr2=0,relPath=0;
DWORD len1=0,len2=0,sameIdx=0,j=0;
- static const WCHAR back[] ={'.','.','\\',0};
TRACE("(%p,%p,%p)\n",iface,pmOther,ppmkRelPath);
@@ -1150,7 +1145,7 @@ FileMonikerImpl_RelativePathTo(IMoniker* iface,IMoniker* pmOther, IMoniker** ppm
if (len2>0 && !(len1==1 && len2==1 && sameIdx==0))
for(j=sameIdx;(tabStr1[j] != NULL); j++)
if (*tabStr1[j]!='\\')
- lstrcatW(relPath,back);
+ lstrcatW(relPath, L"..\\");
/* add items of the second path (similar items with the first path are not included) to the relativePath */
for(j=sameIdx;tabStr2[j]!=NULL;j++)
@@ -1340,8 +1335,6 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
int nb=0,i;
int sizeStr=lstrlenW(lpszPathName);
LPOLESTR *tabStr=0;
- static const WCHAR twoPoint[]={'.','.',0};
- static const WCHAR bkSlash[]={'\\',0};
BOOL addBkSlash;
TRACE("(%p,%s)\n",This,debugstr_w(lpszPathName));
@@ -1364,18 +1357,20 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
if (nb > 0 ){
addBkSlash = TRUE;
- if (wcscmp(tabStr[0],twoPoint)!=0)
+ if (wcscmp(tabStr[0], L".."))
addBkSlash = FALSE;
else
for(i=0;i<nb;i++){
- if ( (wcscmp(tabStr[i],twoPoint)!=0) && (wcscmp(tabStr[i],bkSlash)!=0) ){
+ if (wcscmp(tabStr[i], L"..") && wcscmp(tabStr[i], L"\\"))
+ {
addBkSlash = FALSE;
break;
}
else
- if (wcscmp(tabStr[i],bkSlash)==0 && i<nb-1 && wcscmp(tabStr[i+1],bkSlash)==0){
+ if (!wcscmp(tabStr[i], L"\\") && i < nb - 1 && !wcscmp(tabStr[i+1], L"\\"))
+ {
*tabStr[i]=0;
sizeStr--;
addBkSlash = FALSE;
@@ -1383,7 +1378,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
}
}
- if (wcscmp(tabStr[nb-1],bkSlash)==0)
+ if (!wcscmp(tabStr[nb-1], L"\\"))
addBkSlash = FALSE;
This->filePathName=HeapReAlloc(GetProcessHeap(),0,This->filePathName,(sizeStr+1)*sizeof(WCHAR));
@@ -1394,7 +1389,7 @@ static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* This, LPCOLESTR lpszPa
lstrcatW(This->filePathName,tabStr[i]);
if (addBkSlash)
- lstrcatW(This->filePathName,bkSlash);
+ lstrcatW(This->filePathName, L"\\");
}
free_stringtable(tabStr);
@@ -1447,11 +1442,10 @@ HRESULT FileMoniker_CreateFromDisplayName(LPBC pbc, LPCOLESTR szDisplayName,
LPDWORD pchEaten, IMoniker **ppmk)
{
LPCWSTR end;
- static const WCHAR wszSeparators[] = {':','\\','/','!',0};
for (end = szDisplayName + lstrlenW(szDisplayName);
end && (end != szDisplayName);
- end = memrpbrkW(szDisplayName, end - szDisplayName, wszSeparators))
+ end = memrpbrkW(szDisplayName, end - szDisplayName, L":\\/!"))
{
HRESULT hr;
IRunningObjectTable *rot;
@@ -1538,7 +1532,6 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
{
FileMonikerImpl* newFileMoniker;
HRESULT hr;
- static const WCHAR wszEmpty[] = { 0 };
TRACE("(%p, %s, %p)\n", pUnk, debugstr_guid(riid), ppv);
@@ -1551,7 +1544,7 @@ HRESULT WINAPI FileMoniker_CreateInstance(IClassFactory *iface, IUnknown *pUnk,
if (!newFileMoniker)
return E_OUTOFMEMORY;
- hr = FileMonikerImpl_Construct(newFileMoniker, wszEmpty);
+ hr = FileMonikerImpl_Construct(newFileMoniker, L"");
if (SUCCEEDED(hr))
hr = IMoniker_QueryInterface(&newFileMoniker->IMoniker_iface, riid, ppv);
More information about the wine-cvs
mailing list