mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 18:52:57 +00:00
[SHELL32]
* Sync DoEnvironmentSubst{A,W} with Wine 1.5.26. Fixes issues spotted by Victor Martinez. CORE-7124 #resolve svn path=/trunk/; revision=58854
This commit is contained in:
parent
f892276e85
commit
472acf6982
1 changed files with 53 additions and 38 deletions
|
@ -1492,11 +1492,41 @@ EXTERN_C BOOL WINAPI SHValidateUNC (HWND hwndOwner, LPWSTR pszFile, UINT fConnec
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* 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.
|
EXTERN_C DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
|
||||||
|
{
|
||||||
|
LPSTR dst;
|
||||||
|
BOOL res = FALSE;
|
||||||
|
DWORD len = cchString;
|
||||||
|
|
||||||
|
TRACE("(%s, %d)\n", debugstr_a(pszString), cchString);
|
||||||
|
if (pszString == NULL) /* Really return 0? */
|
||||||
|
return 0;
|
||||||
|
if ((dst = (LPSTR)HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
|
||||||
|
{
|
||||||
|
len = ExpandEnvironmentStringsA(pszString, dst, cchString);
|
||||||
|
/* len includes the terminating 0 */
|
||||||
|
if (len && len < cchString)
|
||||||
|
{
|
||||||
|
res = TRUE;
|
||||||
|
memcpy(pszString, dst, len);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
len = cchString;
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, dst);
|
||||||
|
}
|
||||||
|
return MAKELONG(len, res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* DoEnvironmentSubstW [SHELL32.@]
|
||||||
|
*
|
||||||
|
* Replace all %KEYWORD% in the string with the value of the named
|
||||||
|
* environment variable. If the buffer is too small, the string is not modified.
|
||||||
*
|
*
|
||||||
* PARAMS
|
* PARAMS
|
||||||
* pszString [I] '\0' terminated string with %keyword%.
|
* pszString [I] '\0' terminated string with %keyword%.
|
||||||
|
@ -1504,51 +1534,36 @@ EXTERN_C BOOL WINAPI SHValidateUNC (HWND hwndOwner, LPWSTR pszFile, UINT fConnec
|
||||||
* cchString [I] size of str.
|
* cchString [I] size of str.
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* cchString length in the HIWORD;
|
* Success: The string in the buffer is updated
|
||||||
* TRUE in LOWORD if subst was successful and FALSE in other case
|
* HIWORD: TRUE
|
||||||
*/
|
* LOWORD: characters used in the buffer, including space for the terminating 0
|
||||||
EXTERN_C DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString)
|
* Failure: buffer too small. The string is not modified.
|
||||||
{
|
* HIWORD: FALSE
|
||||||
LPSTR dst;
|
* LOWORD: provided size of the buffer in characters
|
||||||
BOOL res = FALSE;
|
|
||||||
FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString);
|
|
||||||
if (pszString == NULL) /* Really return 0? */
|
|
||||||
return 0;
|
|
||||||
if ((dst = (LPSTR)HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR))))
|
|
||||||
{
|
|
||||||
DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString);
|
|
||||||
if (num && num < cchString) /* dest buffer is too small */
|
|
||||||
{
|
|
||||||
res = TRUE;
|
|
||||||
memcpy(pszString, dst, num);
|
|
||||||
}
|
|
||||||
HeapFree(GetProcessHeap(), 0, dst);
|
|
||||||
}
|
|
||||||
return MAKELONG(res,cchString); /* Always cchString? */
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************************************************************
|
|
||||||
* DoEnvironmentSubstW [SHELL32.@]
|
|
||||||
*
|
|
||||||
* See DoEnvironmentSubstA.
|
|
||||||
*/
|
*/
|
||||||
EXTERN_C DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
|
EXTERN_C DWORD WINAPI DoEnvironmentSubstW(LPWSTR pszString, UINT cchString)
|
||||||
{
|
{
|
||||||
LPWSTR dst;
|
LPWSTR dst;
|
||||||
BOOL res = FALSE;
|
BOOL res = FALSE;
|
||||||
FIXME("(%s, %d): stub\n", debugstr_w(pszString), cchString);
|
DWORD len = cchString;
|
||||||
if ((dst = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(WCHAR))))
|
|
||||||
|
TRACE("(%s, %d)\n", debugstr_w(pszString), cchString);
|
||||||
|
|
||||||
|
if ((cchString < MAXLONG) && (dst = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(WCHAR))))
|
||||||
{
|
{
|
||||||
DWORD num = ExpandEnvironmentStringsW(pszString, dst, cchString);
|
len = ExpandEnvironmentStringsW(pszString, dst, cchString);
|
||||||
if (num)
|
/* len includes the terminating 0 */
|
||||||
|
if (len && len <= cchString)
|
||||||
{
|
{
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
wcscpy(pszString, dst);
|
memcpy(pszString, dst, len * sizeof(WCHAR));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
len = cchString;
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(), 0, dst);
|
HeapFree(GetProcessHeap(), 0, dst);
|
||||||
}
|
}
|
||||||
|
return MAKELONG(len, res);
|
||||||
return MAKELONG(res,cchString);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue