summaryrefslogtreecommitdiffstats
path: root/generic/tclIOSock.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-21 13:05:31 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2014-11-21 13:05:31 (GMT)
commit598b0dc3f2ad75fcacdec6ed563219816b1db0ef (patch)
tree42c6c79cd3ff7aeecc391a5dfd72ed4af2170ae7 /generic/tclIOSock.c
parentc297897b8f3cef07ec0a8b86f7bf56322f8e65dc (diff)
downloadtcl-598b0dc3f2ad75fcacdec6ed563219816b1db0ef.zip
tcl-598b0dc3f2ad75fcacdec6ed563219816b1db0ef.tar.gz
tcl-598b0dc3f2ad75fcacdec6ed563219816b1db0ef.tar.bz2
Fix [743338466549f09e3956d8a86e6f9a8030f227cb|7433384665]: socket error encoding bug.
Diffstat (limited to 'generic/tclIOSock.c')
-rw-r--r--generic/tclIOSock.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c
index 694501f..f69d30f 100644
--- a/generic/tclIOSock.c
+++ b/generic/tclIOSock.c
@@ -12,9 +12,26 @@
#include "tclInt.h"
#if defined(_WIN32) && defined(UNICODE)
-/* On Windows, we always need the ASCII version. */
-# undef gai_strerror
-# define gai_strerror gai_strerrorA
+/* On Windows, we need to do proper Unicode->UTF-8 conversion. */
+
+typedef struct ThreadSpecificData {
+ int initialized;
+ Tcl_DString errorMsg; /* UTF-8 encoded error-message */
+} ThreadSpecificData;
+static Tcl_ThreadDataKey dataKey;
+
+#undef gai_strerror
+static const char *gai_strerror(int code) {
+ ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
+
+ if (tsdPtr->initialized) {
+ Tcl_DStringFree(&tsdPtr->errorMsg);
+ } else {
+ tsdPtr->initialized = 1;
+ }
+ Tcl_WinTCharToUtf(gai_strerrorW(code), -1, &tsdPtr->errorMsg);
+ return Tcl_DStringValue(&tsdPtr->errorMsg);
+}
#endif
/*