shell32: Fix DoEnvironmentSubstA implementation.
This commit is contained in:
parent
ff2f494195
commit
1708adeb97
|
@ -1592,37 +1592,31 @@ BOOL WINAPI SHValidateUNC (HWND hwndOwner, PWSTR pszFile, UINT fConnect)
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* DoEnvironmentSubstA [SHELL32.@]
|
* DoEnvironmentSubstA [SHELL32.@]
|
||||||
*
|
*
|
||||||
* Replace %KEYWORD% in the str with the value of variable KEYWORD
|
* See DoEnvironmentSubstW.
|
||||||
* from environment. If it is not found the %KEYWORD% is left
|
|
||||||
* intact. If the buffer is too small, str is not modified.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* pszString [I] '\0' terminated string with %keyword%.
|
|
||||||
* [O] '\0' terminated string with %keyword% substituted.
|
|
||||||
* cchString [I] size of str.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* cchString length in the HIWORD;
|
|
||||||
* TRUE in LOWORD if subst was successful and FALSE in other case
|
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
|
DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
|
||||||
{
|
{
|
||||||
LPSTR dst;
|
LPSTR dst;
|
||||||
BOOL res = FALSE;
|
BOOL res = FALSE;
|
||||||
FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
|
DWORD len = cchString;
|
||||||
if (pszString == NULL) /* Really return 0? */
|
|
||||||
return 0;
|
TRACE("(%s, %d)\n", debugstr_a(pszString), cchString);
|
||||||
|
|
||||||
if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
|
if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
|
||||||
{
|
{
|
||||||
DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
|
len = ExpandEnvironmentStringsA(pszString, dst, cchString);
|
||||||
if (num && num < cchString) /* dest buffer is too small */
|
/* len includes the terminating 0 */
|
||||||
|
if (len && len < cchString)
|
||||||
{
|
{
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
memcpy(pszString, dst, num);
|
memcpy(pszString, dst, len);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
len = cchString;
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, dst);
|
HeapFree(GetProcessHeap(), 0, dst);
|
||||||
}
|
}
|
||||||
return MAKELONG(res,cchString); /* Always cchString? */
|
return MAKELONG(len, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue