diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-05-25 06:53:47 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2018-05-25 06:53:47 (GMT) |
commit | 51ac01d942b4740082f2d478c512d4108699040b (patch) | |
tree | a198bccb5e62b831594c75da365efbef61d30326 /win/tclWinFile.c | |
parent | a9e7c22c38a58f2248f2bd51529411914cd16e06 (diff) | |
parent | 66ef201ad7df46f74bb93beaec841a5c8a0b1136 (diff) | |
download | tcl-51ac01d942b4740082f2d478c512d4108699040b.zip tcl-51ac01d942b4740082f2d478c512d4108699040b.tar.gz tcl-51ac01d942b4740082f2d478c512d4108699040b.tar.bz2 |
merge 8.6
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r-- | win/tclWinFile.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c index 333c526..8711d27 100644 --- a/win/tclWinFile.c +++ b/win/tclWinFile.c @@ -1417,13 +1417,13 @@ TclpGetUserHome( Tcl_DString *bufferPtr) /* Uninitialized or free DString filled with * name of user's home directory. */ { - const char *result = NULL; + char *result = NULL; USER_INFO_1 *uiPtr, **uiPtrPtr = &uiPtr; Tcl_DString ds; int nameLen = -1; int badDomain = 0; char *domain; - WCHAR *wName, *wHomeDir, *wDomain, **wDomainPtr = &wDomain; + WCHAR *wName, *wHomeDir, *wDomain; WCHAR buf[MAX_PATH]; Tcl_DStringInit(bufferPtr); @@ -1432,7 +1432,7 @@ TclpGetUserHome( if (domain != NULL) { Tcl_DStringInit(&ds); wName = Tcl_UtfToUniCharDString(domain + 1, -1, &ds); - badDomain = NetGetDCName(NULL, wName, (LPBYTE *) wDomainPtr); + badDomain = NetGetDCName(NULL, wName, (LPBYTE *) &wDomain); Tcl_DStringFree(&ds); nameLen = domain - name; } @@ -1440,25 +1440,27 @@ TclpGetUserHome( Tcl_DStringInit(&ds); wName = Tcl_UtfToUniCharDString(name, nameLen, &ds); if (NetUserGetInfo(wDomain, wName, 1, (LPBYTE *) uiPtrPtr) == 0) { + DWORD i, size = MAX_PATH; wHomeDir = uiPtr->usri1_home_dir; if ((wHomeDir != NULL) && (wHomeDir[0] != L'\0')) { - Tcl_UniCharToUtfDString(wHomeDir, lstrlenW(wHomeDir), + size = lstrlenW(wHomeDir); + Tcl_UniCharToUtfDString(wHomeDir, size, bufferPtr); } else { /* * User exists but has no home dir. Return * "{GetProfilesDirectory}/<user>". */ - DWORD i, size = MAX_PATH; GetProfilesDirectoryW(buf, &size); - for (i = 0; i < size; ++i){ - if (buf[i] == '\\') buf[i] = '/'; - } Tcl_UniCharToUtfDString(buf, size-1, bufferPtr); - Tcl_DStringAppend(bufferPtr, "/", -1); - Tcl_DStringAppend(bufferPtr, name, -1); + Tcl_DStringAppend(bufferPtr, "/", 1); + Tcl_DStringAppend(bufferPtr, name, nameLen); } result = Tcl_DStringValue(bufferPtr); + /* be sure we returns normalized path */ + for (i = 0; i < size; ++i){ + if (result[i] == '\\') result[i] = '/'; + } NetApiBufferFree((void *) uiPtr); } Tcl_DStringFree(&ds); |