Sync to Wine-20050111:
Michael Stefaniuc <mstefani(a)redhat.de>
- Do not check for non NULL pointer before HeapFree'ing it. It's
redundant.
Hans Leidekker <hans(a)it.vu.nl>
- Implement and test URLIS_URL flag in UrlIs().
Jon Griffiths <jon_p_griffiths(a)yahoo.com>
- Const correctness fix.
- Remove unneeded headers to reduce unneeded rebuilds.
- Include shlwapi.h to get prototypes, and correct 2 wrong ones.
- Documentation fix.
Michael Stefaniuc <mstefani(a)redhat.de>
- Missing HeapFree's + 1 LocalFree (found by smatch).
Eric Pouech <pouech-eric(a)wanadoo.fr>
- Removed excessive statement (break after return or goto, not useful
break, not needed vars...)
Jacek Caban <jack(a)itma.pwr.wroc.pl>
- Get rid of W->A calls.
Mike McCormack <mike(a)codeweavers.com>
- Use CreateEventW in preference to CreateEventA for unnamed events.
Francois Gouget <fgouget(a)free.fr>
- Remove unneeded NULL casts.
James Hawkins <truiken(a)gmail.com>
- use only stored result of Interlocked* in AddRef/Release
- expand TRACEs to display the ref count
Modified: trunk/reactos/lib/shlwapi/msgbox.c
Modified: trunk/reactos/lib/shlwapi/ordinal.c
Modified: trunk/reactos/lib/shlwapi/regstream.c
Modified: trunk/reactos/lib/shlwapi/stopwatch.c
Modified: trunk/reactos/lib/shlwapi/string.c
Modified: trunk/reactos/lib/shlwapi/thread.c
Modified: trunk/reactos/lib/shlwapi/url.c
Modified: trunk/reactos/lib/shlwapi/wsprintf.c
_____
Modified: trunk/reactos/lib/shlwapi/msgbox.c
--- trunk/reactos/lib/shlwapi/msgbox.c 2005-01-12 22:57:30 UTC (rev
13000)
+++ trunk/reactos/lib/shlwapi/msgbox.c 2005-01-12 23:04:52 UTC (rev
13001)
@@ -273,8 +273,7 @@
iRetVal = SHMessageBoxCheckW(hWnd, szTextBuff, lpszTitle ?
szTitleBuff : NULL,
dwType, iRet, szIdBuff);
- if (szTextBuff)
- HeapFree(GetProcessHeap(), 0, szTextBuff);
+ HeapFree(GetProcessHeap(), 0, szTextBuff);
return iRetVal;
}
_____
Modified: trunk/reactos/lib/shlwapi/ordinal.c
--- trunk/reactos/lib/shlwapi/ordinal.c 2005-01-12 22:57:30 UTC (rev
13000)
+++ trunk/reactos/lib/shlwapi/ordinal.c 2005-01-12 23:04:52 UTC (rev
13001)
@@ -42,15 +42,12 @@
#include "shlguid.h"
#include "wingdi.h"
#include "shlobj.h"
-#include "olectl.h"
#include "shellapi.h"
#include "commdlg.h"
#include "wine/unicode.h"
-#include "servprov.h"
#include "winreg.h"
#include "wine/debug.h"
#include "shlwapi.h"
-#include "winnt.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
@@ -611,7 +608,7 @@
*buflen, NULL, NULL);
*buflen = buflenW ? convlen : 0;
- if(langbufW) HeapFree(GetProcessHeap(), 0, langbufW);
+ HeapFree(GetProcessHeap(), 0, langbufW);
return retval;
}
@@ -621,9 +618,9 @@
* Convert a GUID to a string.
*
* PARAMS
- * guid [I] GUID to convert
- * str [O] Destination for string
- * cmax [I] Length of output buffer
+ * guid [I] GUID to convert
+ * lpszDest [O] Destination for string
+ * cchMax [I] Length of output buffer
*
* RETURNS
* The length of the string created.
@@ -651,15 +648,35 @@
/***********************************************************************
**
* @ [SHLWAPI.24]
*
- * Unicode version of SHStringFromGUIDA.
+ * Convert a GUID to a string.
+ *
+ * PARAMS
+ * guid [I] GUID to convert
+ * str [O] Destination for string
+ * cmax [I] Length of output buffer
+ *
+ * RETURNS
+ * The length of the string created.
*/
INT WINAPI SHStringFromGUIDW(REFGUID guid, LPWSTR lpszDest, INT cchMax)
{
- char xguid[40];
- INT iLen = SHStringFromGUIDA(guid, xguid, cchMax);
+ WCHAR xguid[40];
+ INT iLen;
+ static const WCHAR wszFormat[] =
{'{','%','0','8','l','X','-','%','0','4','X','-','%','0','4','X','-',
+
'%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X','%',
'0','2','X','%','0','2',
+
'X','%','0','2','X','%','0','2','X','}',0};
- if (iLen)
- MultiByteToWideChar(CP_ACP, 0, xguid, -1, lpszDest, cchMax);
+ TRACE("(%s,%p,%d)\n", debugstr_guid(guid), lpszDest, cchMax);
+
+ sprintfW(xguid, wszFormat, guid->Data1, guid->Data2, guid->Data3,
+ guid->Data4[0], guid->Data4[1], guid->Data4[2],
guid->Data4[3],
+ guid->Data4[4], guid->Data4[5], guid->Data4[6],
guid->Data4[7]);
+
+ iLen = strlenW(xguid) + 1;
+
+ if (iLen > cchMax)
+ return 0;
+ memcpy(lpszDest, xguid, iLen*sizeof(WCHAR));
return iLen;
}
@@ -1940,7 +1957,7 @@
mi.fMask = MIIM_SUBMENU;
if (!GetMenuItemInfoA(hMenu, uID, 0, &mi))
- return (HMENU)NULL;
+ return NULL;
return mi.hSubMenu;
}
@@ -2422,8 +2439,8 @@
wc.cbClsExtra = 0;
wc.cbWndExtra = 4;
wc.hInstance = shlwapi_hInstance;
- wc.hIcon = (HICON)0;
- wc.hCursor = LoadCursorA((HINSTANCE)0, (LPSTR)IDC_ARROW);
+ wc.hIcon = NULL;
+ wc.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
wc.lpszMenuName = NULL;
wc.lpszClassName = szClass;
@@ -2709,8 +2726,8 @@
wc.cbClsExtra = 0;
wc.cbWndExtra = 4;
wc.hInstance = shlwapi_hInstance;
- wc.hIcon = (HICON)0;
- wc.hCursor = LoadCursorA((HINSTANCE)0, (LPSTR)IDC_ARROW);
+ wc.hIcon = NULL;
+ wc.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
wc.lpszMenuName = NULL;
wc.lpszClassName = szClass;
@@ -2723,10 +2740,10 @@
hWndParent, hMenu, shlwapi_hInstance, 0);
if (hWnd)
{
- SetWindowLongA(hWnd, DWL_MSGRESULT, z);
+ SetWindowLongW(hWnd, DWL_MSGRESULT, z);
if (wndProc)
- SetWindowLongPtrA(hWnd, GWLP_WNDPROC, wndProc);
+ SetWindowLongPtrW(hWnd, GWLP_WNDPROC, wndProc);
}
return hWnd;
}
_____
Modified: trunk/reactos/lib/shlwapi/regstream.c
--- trunk/reactos/lib/shlwapi/regstream.c 2005-01-12 22:57:30 UTC
(rev 13000)
+++ trunk/reactos/lib/shlwapi/regstream.c 2005-01-12 23:04:52 UTC
(rev 13001)
@@ -94,8 +94,7 @@
{
TRACE(" destroying SHReg IStream (%p)\n",This);
- if (This->pbBuffer)
- HeapFree(GetProcessHeap(),0,This->pbBuffer);
+ HeapFree(GetProcessHeap(),0,This->pbBuffer);
if (This->hKey)
RegCloseKey(This->hKey);
@@ -388,8 +387,7 @@
dwType == REG_BINARY)
return IStream_Create(hStrKey, lpBuff, dwLength);
- if (lpBuff)
- HeapFree (GetProcessHeap(), 0, lpBuff);
+ HeapFree (GetProcessHeap(), 0, lpBuff);
if (hStrKey)
RegCloseKey(hStrKey);
return NULL;
@@ -418,8 +416,7 @@
dwType == REG_BINARY)
return IStream_Create(hStrKey, lpBuff, dwLength);
- if (lpBuff)
- HeapFree (GetProcessHeap(), 0, lpBuff);
+ HeapFree (GetProcessHeap(), 0, lpBuff);
if (hStrKey)
RegCloseKey(hStrKey);
return NULL;
_____
Modified: trunk/reactos/lib/shlwapi/stopwatch.c
--- trunk/reactos/lib/shlwapi/stopwatch.c 2005-01-12 22:57:30 UTC
(rev 13000)
+++ trunk/reactos/lib/shlwapi/stopwatch.c 2005-01-12 23:04:52 UTC
(rev 13001)
@@ -32,15 +32,10 @@
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
-#include "wine/unicode.h"
#include "windef.h"
#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
#include "winreg.h"
#include "winternl.h"
-#define NO_SHLWAPI_STREAM
-#include "shlwapi.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(shell);
_____
Modified: trunk/reactos/lib/shlwapi/string.c
--- trunk/reactos/lib/shlwapi/string.c 2005-01-12 22:57:30 UTC (rev
13000)
+++ trunk/reactos/lib/shlwapi/string.c 2005-01-12 23:04:52 UTC (rev
13001)
@@ -599,7 +599,7 @@
while (lpszStr <= lpszEnd && *lpszStr)
{
- if (!ChrCmpIA(*lpszSearch, *lpszStr))
+ if (!ChrCmpIW(*lpszSearch, *lpszStr))
{
if (!StrCmpNIW(lpszStr, lpszSearch, iLen))
lpszRet = (LPWSTR)lpszStr;
@@ -2186,7 +2186,7 @@
return 1;
else
{
- iDiff =
SHLWAPI_ChrCmpHelperA(*lpszStr,*lpszComp,NORM_IGNORECASE);
+ iDiff =
SHLWAPI_ChrCmpHelperW(*lpszStr,*lpszComp,NORM_IGNORECASE);
if (iDiff > 0)
return 1;
else if (iDiff < 0)
@@ -2208,12 +2208,12 @@
LONGLONG dLimit;
double dDivisor;
double dNormaliser;
- LPCSTR lpszFormat;
- CHAR wPrefix;
+ LPCWSTR lpwszFormat;
+ WCHAR wPrefix;
} SHLWAPI_BYTEFORMATS;
/***********************************************************************
**
- * StrFormatByteSize64A [SHLWAPI.@]
+ * StrFormatByteSizeW [SHLWAPI.@]
*
* Create a string containing an abbreviated byte count of up to
2^63-1.
*
@@ -2228,12 +2228,12 @@
* NOTES
* There is no StrFormatByteSize64W function, it is called
StrFormatByteSizeW().
*/
-LPSTR WINAPI StrFormatByteSize64A(LONGLONG llBytes, LPSTR lpszDest,
UINT cchMax)
+LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest,
UINT cchMax)
{
- static const char szBytes[] = "%ld bytes";
- static const char sz3_0[] = "%3.0f";
- static const char sz3_1[] = "%3.1f";
- static const char sz3_2[] = "%3.2f";
+ static const WCHAR wszBytes[] = {'%','l','d','
','b','y','t','e','s',0};
+ static const WCHAR wsz3_0[] =
{'%','3','.','0','f',0};
+ static const WCHAR wsz3_1[] =
{'%','3','.','1','f',0};
+ static const WCHAR wsz3_2[] =
{'%','3','.','2','f',0};
#define KB ((ULONGLONG)1024)
#define MB (KB*KB)
@@ -2243,25 +2243,25 @@
static const SHLWAPI_BYTEFORMATS bfFormats[] =
{
- { 10*KB, 10.24, 100.0, sz3_2, 'K' }, /* 10 KB */
- { 100*KB, 102.4, 10.0, sz3_1, 'K' }, /* 100 KB */
- { 1000*KB, 1024.0, 1.0, sz3_0, 'K' }, /* 1000 KB */
- { 10*MB, 10485.76, 100.0, sz3_2, 'M' }, /* 10 MB */
- { 100*MB, 104857.6, 10.0, sz3_1, 'M' }, /* 100 MB */
- { 1000*MB, 1048576.0, 1.0, sz3_0, 'M' }, /* 1000 MB */
- { 10*GB, 10737418.24, 100.0, sz3_2, 'G' }, /* 10 GB */
- { 100*GB, 107374182.4, 10.0, sz3_1, 'G' }, /* 100 GB */
- { 1000*GB, 1073741824.0, 1.0, sz3_0, 'G' }, /* 1000 GB */
- { 10*TB, 10485.76, 100.0, sz3_2, 'T' }, /* 10 TB */
- { 100*TB, 104857.6, 10.0, sz3_1, 'T' }, /* 100 TB */
- { 1000*TB, 1048576.0, 1.0, sz3_0, 'T' }, /* 1000 TB */
- { 10*PB, 10737418.24, 100.00, sz3_2, 'P' }, /* 10 PB */
- { 100*PB, 107374182.4, 10.00, sz3_1, 'P' }, /* 100 PB */
- { 1000*PB, 1073741824.0, 1.00, sz3_0, 'P' }, /* 1000 PB */
- { 0, 10995116277.76, 100.00, sz3_2, 'E' } /* EB's, catch all */
+ { 10*KB, 10.24, 100.0, wsz3_2, 'K' }, /* 10 KB */
+ { 100*KB, 102.4, 10.0, wsz3_1, 'K' }, /* 100 KB */
+ { 1000*KB, 1024.0, 1.0, wsz3_0, 'K' }, /* 1000 KB */
+ { 10*MB, 10485.76, 100.0, wsz3_2, 'M' }, /* 10 MB */
+ { 100*MB, 104857.6, 10.0, wsz3_1, 'M' }, /* 100 MB */
+ { 1000*MB, 1048576.0, 1.0, wsz3_0, 'M' }, /* 1000 MB */
+ { 10*GB, 10737418.24, 100.0, wsz3_2, 'G' }, /* 10 GB */
+ { 100*GB, 107374182.4, 10.0, wsz3_1, 'G' }, /* 100 GB */
+ { 1000*GB, 1073741824.0, 1.0, wsz3_0, 'G' }, /* 1000 GB */
+ { 10*TB, 10485.76, 100.0, wsz3_2, 'T' }, /* 10 TB */
+ { 100*TB, 104857.6, 10.0, wsz3_1, 'T' }, /* 100 TB */
+ { 1000*TB, 1048576.0, 1.0, wsz3_0, 'T' }, /* 1000 TB */
+ { 10*PB, 10737418.24, 100.00, wsz3_2, 'P' }, /* 10 PB */
+ { 100*PB, 107374182.4, 10.00, wsz3_1, 'P' }, /* 100 PB */
+ { 1000*PB, 1073741824.0, 1.00, wsz3_0, 'P' }, /* 1000 PB */
+ { 0, 10995116277.76, 100.00, wsz3_2, 'E' } /* EB's, catch all */
};
- char szBuff[32];
- char szAdd[4];
+ WCHAR wszBuff[32];
+ WCHAR wszAdd[] = {' ','?','B',0};
double dBytes;
UINT i = 0;
@@ -2272,7 +2272,7 @@
if (llBytes < 1024) /* 1K */
{
- snprintf (lpszDest, cchMax, szBytes, (long)llBytes);
+ snprintfW(lpszDest, cchMax, wszBytes, (long)llBytes);
return lpszDest;
}
@@ -2298,30 +2298,26 @@
dBytes = floor(dBytes / bfFormats[i].dDivisor) /
bfFormats[i].dNormaliser;
- sprintf(szBuff, bfFormats[i].lpszFormat, dBytes);
- szAdd[0] = ' ';
- szAdd[1] = bfFormats[i].wPrefix;
- szAdd[2] = 'B';
- szAdd[3] = '\0';
- strcat(szBuff, szAdd);
- strncpy(lpszDest, szBuff, cchMax);
+ sprintfW(wszBuff, bfFormats[i].lpwszFormat, dBytes);
+ wszAdd[1] = bfFormats[i].wPrefix;
+ strcatW(wszBuff, wszAdd);
+ strncpyW(lpszDest, wszBuff, cchMax);
return lpszDest;
}
/***********************************************************************
**
- * StrFormatByteSizeW [SHLWAPI.@]
+ * StrFormatByteSize64A [SHLWAPI.@]
*
- * See StrFormatByteSize64A.
+ * See StrFormatByteSizeW.
*/
-LPWSTR WINAPI StrFormatByteSizeW(LONGLONG llBytes, LPWSTR lpszDest,
- UINT cchMax)
+LPSTR WINAPI StrFormatByteSize64A(LONGLONG llBytes, LPSTR lpszDest,
UINT cchMax)
{
- char szBuff[32];
+ WCHAR wszBuff[32];
- StrFormatByteSize64A(llBytes, szBuff, sizeof(szBuff));
+ StrFormatByteSizeW(llBytes, wszBuff, sizeof(wszBuff)/sizeof(WCHAR));
if (lpszDest)
- MultiByteToWideChar(CP_ACP, 0, szBuff, -1, lpszDest, cchMax);
+ WideCharToMultiByte(CP_ACP, 0, wszBuff, -1, lpszDest, cchMax, 0,
0);
return lpszDest;
}
@@ -2560,6 +2556,7 @@
{
SHTruncateString(mem, *lpiLen);
lstrcpynA(lpDstStr, mem, *lpiLen + 1);
+ HeapFree(GetProcessHeap(), 0, mem);
return *lpiLen + 1;
}
HeapFree(GetProcessHeap(), 0, mem);
@@ -2568,7 +2565,6 @@
lpDstStr[*lpiLen] = '\0';
return *lpiLen;
}
- break;
default:
break;
}
_____
Modified: trunk/reactos/lib/shlwapi/thread.c
--- trunk/reactos/lib/shlwapi/thread.c 2005-01-12 22:57:30 UTC (rev
13000)
+++ trunk/reactos/lib/shlwapi/thread.c 2005-01-12 23:04:52 UTC (rev
13001)
@@ -288,7 +288,7 @@
ti.pfnCallback = pfnCallback;
ti.pData = pData;
ti.bInitCom = dwFlags & CTF_COINIT ? TRUE : FALSE;
- ti.hEvent = CreateEventA(NULL,FALSE,FALSE,NULL);
+ ti.hEvent = CreateEventW(NULL,FALSE,FALSE,NULL);
/* Hold references to the current thread and IE process, if desired
*/
if(dwFlags & CTF_THREAD_REF)
_____
Modified: trunk/reactos/lib/shlwapi/url.c
--- trunk/reactos/lib/shlwapi/url.c 2005-01-12 22:57:30 UTC (rev
13000)
+++ trunk/reactos/lib/shlwapi/url.c 2005-01-12 23:04:52 UTC (rev
13001)
@@ -444,6 +444,7 @@
break;
default:
FIXME("how did we get here - state=%d\n", state);
+ HeapFree(GetProcessHeap(), 0, lpszUrlCpy);
return E_INVALIDARG;
}
}
@@ -1416,7 +1417,7 @@
* return the same digests for the same URL.
*/
WideCharToMultiByte(0, 0, pszUrl, -1, szUrl, MAX_PATH, 0, 0);
- HashData((PBYTE)szUrl, (int)strlen(szUrl), lpDest, nDestLen);
+ HashData((const BYTE*)szUrl, (int)strlen(szUrl), lpDest, nDestLen);
return S_OK;
}
@@ -1631,6 +1632,8 @@
DWORD res1;
LPCSTR last;
+ TRACE("(%s %d)\n", debugstr_a(pszUrl), Urlis);
+
switch (Urlis) {
case URLIS_OPAQUE:
@@ -1650,6 +1653,8 @@
return (last >= pszUrl && (*last == '/' || *last ==
'\\' ));
case URLIS_URL:
+ return PathIsURLA(pszUrl);
+
case URLIS_NOHISTORY:
case URLIS_APPLIABLE:
case URLIS_HASQUERY:
@@ -1671,6 +1676,8 @@
DWORD res1;
LPCWSTR last;
+ TRACE("(%s %d)\n", debugstr_w(pszUrl), Urlis);
+
switch (Urlis) {
case URLIS_OPAQUE:
@@ -1690,6 +1697,8 @@
return (last >= pszUrl && (*last == '/' || *last ==
'\\'));
case URLIS_URL:
+ return PathIsURLW(pszUrl);
+
case URLIS_NOHISTORY:
case URLIS_APPLIABLE:
case URLIS_HASQUERY:
_____
Modified: trunk/reactos/lib/shlwapi/wsprintf.c
--- trunk/reactos/lib/shlwapi/wsprintf.c 2005-01-12 22:57:30 UTC
(rev 13000)
+++ trunk/reactos/lib/shlwapi/wsprintf.c 2005-01-12 23:04:52 UTC
(rev 13001)
@@ -28,8 +28,8 @@
#include "windef.h"
#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
+#define NO_SHLWAPI_REG
+#include "shlwapi.h"
#include "wine/debug.h"
@@ -284,7 +284,7 @@
* Success: The number of characters written.
* Failure: -1.
*/
-INT WINAPI wvnsprintfA( LPSTR buffer, UINT maxlen, LPCSTR spec, va_list
args )
+INT WINAPI wvnsprintfA( LPSTR buffer, INT maxlen, LPCSTR spec, va_list
args )
{
WPRINTF_FORMAT format;
LPSTR p = buffer;
@@ -389,7 +389,7 @@
*
* See wvnsprintfA.
*/
-INT WINAPI wvnsprintfW( LPWSTR buffer, UINT maxlen, LPCWSTR spec,
va_list args )
+INT WINAPI wvnsprintfW( LPWSTR buffer, INT maxlen, LPCWSTR spec,
va_list args )
{
WPRINTF_FORMAT format;
LPWSTR p = buffer;