summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2018-10-09 13:51:56 (GMT)
committerdgp <dgp@users.sourceforge.net>2018-10-09 13:51:56 (GMT)
commiteec0f0f9da09e4ffe2e4daa880ef23835e3d48c0 (patch)
tree9698dc78e0851ec71411c3b5de28e4969fca8da5 /generic
parente13c5f55a1b87cdf7eb3f5da7bb71ac0747ee6e0 (diff)
parentcc4dae5c0f418d304a44bb10c87c624b478b6441 (diff)
downloadtcl-eec0f0f9da09e4ffe2e4daa880ef23835e3d48c0.zip
tcl-eec0f0f9da09e4ffe2e4daa880ef23835e3d48c0.tar.gz
tcl-eec0f0f9da09e4ffe2e4daa880ef23835e3d48c0.tar.bz2
merge 8.6
Diffstat (limited to 'generic')
-rw-r--r--generic/tclStubInit.c57
1 files changed, 15 insertions, 42 deletions
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index b28d501..cbf4084 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -12,6 +12,10 @@
#include "tclInt.h"
#include "tommath.h"
+#ifdef __CYGWIN__
+# include <wchar.h>
+#endif
+
#ifdef __GNUC__
#pragma GCC dependency "tcl.decls"
#pragma GCC dependency "tclInt.decls"
@@ -106,10 +110,6 @@ static unsigned short TclWinNToHS(unsigned short ns) {
# define TclWinFlushDirtyChannels doNothing
# define TclWinResetInterfaces doNothing
-#if TCL_UTF_MAX < 4
-static Tcl_Encoding winTCharEncoding;
-#endif
-
static int
TclpIsAtty(int fd)
{
@@ -188,25 +188,11 @@ Tcl_WinUtfToTChar(
int len,
Tcl_DString *dsPtr)
{
-#if TCL_UTF_MAX > 3
- WCHAR *wp;
- int size = MultiByteToWideChar(CP_UTF8, 0, string, len, 0, 0);
-
Tcl_DStringInit(dsPtr);
- Tcl_DStringSetLength(dsPtr, 2*size+2);
- wp = (WCHAR *)Tcl_DStringValue(dsPtr);
- MultiByteToWideChar(CP_UTF8, 0, string, len, wp, size+1);
- if (len == -1) --size; /* account for 0-byte at string end */
- Tcl_DStringSetLength(dsPtr, 2*size);
- wp[size] = 0;
- return (char *)wp;
-#else
- if (!winTCharEncoding) {
- winTCharEncoding = Tcl_GetEncoding(0, "unicode");
+ if (!string) {
+ return NULL;
}
- return Tcl_UtfToExternalDString(winTCharEncoding,
- string, len, dsPtr);
-#endif
+ return (char *)Tcl_UtfToUniCharDString(string, len, dsPtr);
}
char *
@@ -215,29 +201,16 @@ Tcl_WinTCharToUtf(
int len,
Tcl_DString *dsPtr)
{
-#if TCL_UTF_MAX > 3
- char *p;
- int size;
-
- if (len > 0) {
- len /= 2;
- }
- size = WideCharToMultiByte(CP_UTF8, 0, string, len, 0, 0, NULL, NULL);
Tcl_DStringInit(dsPtr);
- Tcl_DStringSetLength(dsPtr, size+1);
- p = (char *)Tcl_DStringValue(dsPtr);
- WideCharToMultiByte(CP_UTF8, 0, string, len, p, size, NULL, NULL);
- if (len == -1) --size; /* account for 0-byte at string end */
- Tcl_DStringSetLength(dsPtr, size);
- p[size] = 0;
- return p;
-#else
- if (!winTCharEncoding) {
- winTCharEncoding = Tcl_GetEncoding(0, "unicode");
+ if (!string) {
+ return NULL;
}
- return Tcl_ExternalToUtfDString(winTCharEncoding,
- string, len, dsPtr);
-#endif
+ if (len < 0) {
+ len = wcslen((wchar_t *)string);
+ } else {
+ len /= 2;
+ }
+ return Tcl_UniCharToUtfDString((Tcl_UniChar *)string, len, dsPtr);
}
#if defined(TCL_WIDE_INT_IS_LONG)