summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to 'win')
-rw-r--r--win/tclWinFile.c28
-rw-r--r--win/tclWinInit.c17
2 files changed, 26 insertions, 19 deletions
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index 30d08fa..b7af7d0 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.61 2004/01/29 10:28:23 vincentdarley Exp $
+ * RCS: @(#) $Id: tclWinFile.c,v 1.62 2004/04/07 22:04:30 hobbs Exp $
*/
//#define _WIN32_WINNT 0x0500
@@ -666,12 +666,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
@@ -686,8 +685,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;
@@ -701,12 +700,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;
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 98a6936..fb3c026 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -7,7 +7,7 @@
* Copyright (c) 1998-1999 by Scriptics Corporation.
* All rights reserved.
*
- * RCS: @(#) $Id: tclWinInit.c,v 1.45 2004/02/12 23:19:17 mdejong Exp $
+ * RCS: @(#) $Id: tclWinInit.c,v 1.46 2004/04/07 22:04:31 hobbs Exp $
*/
#include "tclWinInt.h"
@@ -172,7 +172,7 @@ TclpInitPlatform()
* Called at process initialization time.
*
* Results:
- * None.
+ * Return 0, indicating that the UTF is clean.
*
* Side effects:
* None.
@@ -180,7 +180,7 @@ TclpInitPlatform()
*---------------------------------------------------------------------------
*/
-void
+int
TclpInitLibraryPath(path)
CONST char *path; /* Potentially dirty UTF string that is */
/* the path to the executable name. */
@@ -337,6 +337,8 @@ TclpInitLibraryPath(path)
}
TclSetLibraryPath(pathPtr);
+
+ return 0; /* 0 indicates that pathPtr is clean (true) utf */
}
/*
@@ -576,14 +578,17 @@ TclpSetInitialEncodings()
char buf[4 + TCL_INTEGER_SPACE];
if (libraryPathEncodingFixed == 0) {
- int platformId;
+ int platformId, useWide;
+
platformId = TclWinGetPlatformId();
- TclWinSetInterfaces(platformId == VER_PLATFORM_WIN32_NT);
+ useWide = ((platformId == VER_PLATFORM_WIN32_NT)
+ || (platformId == VER_PLATFORM_WIN32_CE));
+ TclWinSetInterfaces(useWide);
wsprintfA(buf, "cp%d", GetACP());
Tcl_SetSystemEncoding(NULL, buf);
- if (platformId != VER_PLATFORM_WIN32_NT) {
+ if (!useWide) {
Tcl_Obj *pathPtr = TclGetLibraryPath();
if (pathPtr != NULL) {
int i, objc;