summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-06 14:49:23 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2015-10-06 14:49:23 (GMT)
commit2738bd34505c7fa7a1d68fe8f5bbaa2f5d35c12c (patch)
tree0f4f9046805988cc273ce06b3db5fd75c8167c21
parente38804664b6a2b090714657b23bcfe211c58347c (diff)
parent40ba2e067496a7fab51129617bbcd0f5553f285f (diff)
downloadtcl-2738bd34505c7fa7a1d68fe8f5bbaa2f5d35c12c.zip
tcl-2738bd34505c7fa7a1d68fe8f5bbaa2f5d35c12c.tar.gz
tcl-2738bd34505c7fa7a1d68fe8f5bbaa2f5d35c12c.tar.bz2
Fix [b42a851475]: file normalize ~user returns wrong directory on Windows
-rwxr-xr-xwin/configure4
-rw-r--r--win/makefile.vc2
-rw-r--r--win/tcl.m44
-rwxr-xr-xwin/tclWinFile.c19
4 files changed, 19 insertions, 10 deletions
diff --git a/win/configure b/win/configure
index 4ca795c..4ce23f9 100755
--- a/win/configure
+++ b/win/configure
@@ -3587,7 +3587,7 @@ echo $ECHO_N "checking compiler flags... $ECHO_C" >&6
if test "${GCC}" = "yes" ; then
SHLIB_LD=""
SHLIB_LD_LIBS='${LIBS}'
- LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32"
+ LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
STLIB_LD='${AR} cr'
@@ -3803,7 +3803,7 @@ echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6
fi
fi
- LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib"
+ LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
case "x`echo \${VisualStudioVersion}`" in
x1[4-9]*)
diff --git a/win/makefile.vc b/win/makefile.vc
index 024ecb0..70f3f6e 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -550,7 +550,7 @@ dlllflags = $(lflags) -dll
conlflags = $(lflags) -subsystem:console
guilflags = $(lflags) -subsystem:windows
-baselibs = netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib
+baselibs = netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib
# Avoid 'unresolved external symbol __security_cookie' errors.
# c.f. http://support.microsoft.com/?id=894573
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
diff --git a/win/tcl.m4 b/win/tcl.m4
index 80a5086..db86f6c 100644
--- a/win/tcl.m4
+++ b/win/tcl.m4
@@ -673,7 +673,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
if test "${GCC}" = "yes" ; then
SHLIB_LD=""
SHLIB_LD_LIBS='${LIBS}'
- LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -lws2_32"
+ LIBS="-lnetapi32 -lkernel32 -luser32 -ladvapi32 -luserenv -lws2_32"
# mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't
LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32"
STLIB_LD='${AR} cr'
@@ -834,7 +834,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [
fi
fi
- LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib ws2_32.lib"
+ LIBS="netapi32.lib kernel32.lib user32.lib advapi32.lib userenv.lib ws2_32.lib"
case "x`echo \${VisualStudioVersion}`" in
x1[[4-9]]*)
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index f6e3a4b..be9c947 100755
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -17,7 +17,11 @@
#include <winioctl.h>
#include <shlobj.h>
#include <lm.h> /* For TclpGetUserHome(). */
+#include <userenv.h> /* For TclpGetUserHome(). */
+#ifdef _MSC_VER
+# pragma comment(lib, "userenv.lib")
+#endif
/*
* The number of 100-ns intervals between the Windows system epoch (1601-01-01
* on the proleptic Gregorian calendar) and the Posix epoch (1970-01-01).
@@ -1461,12 +1465,17 @@ TclpGetUserHome(
} else {
/*
* User exists but has no home dir. Return
- * "{Windows Drive}:/users/default".
+ * "{GetProfilesDirectory}/<user>".
*/
-
- GetWindowsDirectoryW(buf, MAX_PATH);
- Tcl_UniCharToUtfDString(buf, 2, bufferPtr);
- TclDStringAppendLiteral(bufferPtr, "/users/default");
+ DWORD size = MAX_PATH;
+ int i;
+ 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);
}
result = Tcl_DStringValue(bufferPtr);
NetApiBufferFree((void *) uiPtr);