summaryrefslogtreecommitdiffstats
path: root/win/tclWinInit.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-06-25 07:22:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-06-25 07:22:19 (GMT)
commit0839047d8bed631eeb82c7c3e26b0f13461717e6 (patch)
tree19316d62ae770b7d56b6bea97f134e33322c4691 /win/tclWinInit.c
parente2a79c2604e79b36ec065a7bb44ec57eaca5ed8a (diff)
downloadtcl-0839047d8bed631eeb82c7c3e26b0f13461717e6.zip
tcl-0839047d8bed631eeb82c7c3e26b0f13461717e6.tar.gz
tcl-0839047d8bed631eeb82c7c3e26b0f13461717e6.tar.bz2
Simplify ToUtf(), expecially for TCL_UTF_MAX>3 (with correct surrogate handling).
Fix various typo's
Diffstat (limited to 'win/tclWinInit.c')
-rw-r--r--win/tclWinInit.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index 8e567e3..ff5327d 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -112,7 +112,12 @@ static ProcessGlobalValue sourceLibraryDir =
{0, 0, NULL, NULL, InitializeSourceLibraryDir, NULL, NULL};
static void AppendEnvironment(Tcl_Obj *listPtr, const char *lib);
-static int ToUtf(const WCHAR *wSrc, char *dst);
+
+#if TCL_UTF_MAX < 4
+static void ToUtf(const WCHAR *wSrc, char *dst);
+#else
+#define ToUtf(wSrc, dst) WideCharToMultiByte(CP_UTF8, 0, wSrc, -1, dst, MAX_PATH * TCL_UTF_MAX, NULL, NULL)
+#endif
/*
*---------------------------------------------------------------------------
@@ -435,7 +440,7 @@ InitializeSourceLibraryDir(
*
* ToUtf --
*
- * Convert a char string to a UTF string.
+ * Convert a wchar string to a UTF string.
*
* Results:
* None.
@@ -446,21 +451,19 @@ InitializeSourceLibraryDir(
*---------------------------------------------------------------------------
*/
-static int
+#if TCL_UTF_MAX < 4
+static void
ToUtf(
const WCHAR *wSrc,
char *dst)
{
- char *start;
-
- start = dst;
while (*wSrc != '\0') {
dst += Tcl_UniCharToUtf(*wSrc, dst);
wSrc++;
}
*dst = '\0';
- return (int) (dst - start);
}
+#endif
/*
*---------------------------------------------------------------------------
@@ -660,7 +663,7 @@ TclpSetVariables(
* TclpFindVariable --
*
* Locate the entry in environ for a given name. On Unix this routine is
- * case sensitive, on Windows this matches mioxed case.
+ * case sensitive, on Windows this matches mixed case.
*
* Results:
* The return value is the index in environ of an entry with the name