summaryrefslogtreecommitdiffstats
path: root/win/tclWinFile.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-03-29 18:49:19 (GMT)
committerhobbs <hobbs>2004-03-29 18:49:19 (GMT)
commit4842df1ea67d934dad86802e91e66aeb8ecad9ed (patch)
treece0bae4649cdf08ac4f4a22e22af0af73664e655 /win/tclWinFile.c
parenta5a39131e32f6357e0328e9f4828ed184f2b7a4e (diff)
downloadtcl-4842df1ea67d934dad86802e91e66aeb8ecad9ed.zip
tcl-4842df1ea67d934dad86802e91e66aeb8ecad9ed.tar.gz
tcl-4842df1ea67d934dad86802e91e66aeb8ecad9ed.tar.bz2
* generic/tclInt.h:
* generic/tclEncoding.c (TclFindEncodings, Tcl_FindExecutable): * mac/tclMacInit.c (TclpInitLibraryPath): Correct handling of UTF * unix/tclUnixInit.c (TclpInitLibraryPath): data that is actually * win/tclWinFile.c (TclpFindExecutable): "clean", allowing the * win/tclWinInit.c (TclpInitLibraryPath): loading of Tcl from paths that contain multi-byte chars on Windows [Bug 920667]
Diffstat (limited to 'win/tclWinFile.c')
-rw-r--r--win/tclWinFile.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 13a2c48..6e1dde1 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.6 2003/10/03 17:45:37 vincentdarley Exp $
+ * RCS: @(#) $Id: tclWinFile.c,v 1.44.2.7 2004/03/29 18:49:36 hobbs Exp $
*/
//#define _WIN32_WINNT 0x0500
@@ -665,12 +665,11 @@ NativeWriteReparse(LinkDirectory, buffer)
* application, given its argv[0] value.
*
* Results:
- * A dirty UTF string that is the path to the executable. At this
- * point we may not know the system encoding. Convert the native
- * string value to UTF using the default encoding. The assumption
- * is that we will still be able to parse the path given the path
- * name contains ASCII string and '/' chars do not conflict with
- * other UTF chars.
+ * A clean UTF string that is the path to the executable. At this
+ * point we may not know the system encoding, but we convert the
+ * string value to UTF-8 using core Windows functions. The path name
+ * contains ASCII string and '/' chars do not conflict with other UTF
+ * chars.
*
* Side effects:
* The variable tclNativeExecutableName gets filled in with the file
@@ -685,8 +684,8 @@ TclpFindExecutable(argv0)
CONST char *argv0; /* The value of the application's argv[0]
* (native). */
{
- Tcl_DString ds;
WCHAR wName[MAX_PATH];
+ char name[MAX_PATH * TCL_UTF_MAX];
if (argv0 == NULL) {
return NULL;
@@ -700,12 +699,15 @@ TclpFindExecutable(argv0)
* create this process.
*/
- (*tclWinProcs->getModuleFileNameProc)(NULL, wName, MAX_PATH);
- Tcl_WinTCharToUtf((CONST TCHAR *) wName, -1, &ds);
+ if (GetModuleFileNameW(NULL, wName, MAX_PATH) == 0) {
+ GetModuleFileNameA(NULL, name, sizeof(name));
+ } else {
+ WideCharToMultiByte(CP_UTF8, 0, wName, -1,
+ name, sizeof(name), NULL, NULL);
+ }
- tclNativeExecutableName = ckalloc((unsigned) (Tcl_DStringLength(&ds) + 1));
- strcpy(tclNativeExecutableName, Tcl_DStringValue(&ds));
- Tcl_DStringFree(&ds);
+ tclNativeExecutableName = ckalloc((unsigned) (strlen(name) + 1));
+ strcpy(tclNativeExecutableName, name);
TclWinNoBackslash(tclNativeExecutableName);
return tclNativeExecutableName;