ole32: Use wide-char string literals in filemoniker.c.

Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
Signed-off-by: Huw Davies <huw@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Michael Stefaniuc 2020-11-27 09:00:22 +00:00 committed by Alexandre Julliard
parent 137acffdf4
commit 496c6734e4
1 changed files with 19 additions and 26 deletions

View File

@ -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);