Module: wine Branch: master Commit: 1708adeb97298a3edd5a15f5f72e01fd6619fe51 URL: http://source.winehq.org/git/wine.git/?a=commit;h=1708adeb97298a3edd5a15f5f7...
Author: Detlef Riekenberg wine.dev@web.de Date: Tue Dec 4 11:38:01 2012 +0100
shell32: Fix DoEnvironmentSubstA implementation.
---
dlls/shell32/shellord.c | 34 ++++++++++++++-------------------- 1 files changed, 14 insertions(+), 20 deletions(-)
diff --git a/dlls/shell32/shellord.c b/dlls/shell32/shellord.c index b71d213..fcad032 100644 --- a/dlls/shell32/shellord.c +++ b/dlls/shell32/shellord.c @@ -1590,39 +1590,33 @@ BOOL WINAPI SHValidateUNC (HWND hwndOwner, PWSTR pszFile, UINT fConnect) }
/************************************************************************ - * DoEnvironmentSubstA [SHELL32.@] + * DoEnvironmentSubstA [SHELL32.@] * - * Replace %KEYWORD% in the str with the value of variable KEYWORD - * 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 + * See DoEnvironmentSubstW. */ DWORD WINAPI DoEnvironmentSubstA(LPSTR pszString, UINT cchString) { LPSTR dst; BOOL res = FALSE; - FIXME("(%s, %d) stub\n", debugstr_a(pszString), cchString); - if (pszString == NULL) /* Really return 0? */ - return 0; + DWORD len = cchString; + + TRACE("(%s, %d)\n", debugstr_a(pszString), cchString); + if ((dst = HeapAlloc(GetProcessHeap(), 0, cchString * sizeof(CHAR)))) { - DWORD num = ExpandEnvironmentStringsA(pszString, dst, cchString); - if (num && num < cchString) /* dest buffer is too small */ + len = ExpandEnvironmentStringsA(pszString, dst, cchString); + /* len includes the terminating 0 */ + if (len && len < cchString) { res = TRUE; - memcpy(pszString, dst, num); + memcpy(pszString, dst, len); } + else + len = cchString; + HeapFree(GetProcessHeap(), 0, dst); } - return MAKELONG(res,cchString); /* Always cchString? */ + return MAKELONG(len, res); }
/************************************************************************