summaryrefslogtreecommitdiffstats
path: root/generic/tclIOSock.c
diff options
context:
space:
mode:
authorevilotto <evilotto>2014-11-26 18:17:34 (GMT)
committerevilotto <evilotto>2014-11-26 18:17:34 (GMT)
commit5cd6e3655aa18d12fd25de99de591b2e2074049b (patch)
treeb496abc8bdbca86c65cdc20e6d21f2bc471206c2 /generic/tclIOSock.c
parent6eb9ac605e8119a21ec7d047ba0da0375559d527 (diff)
parent33eb2510ff53b7fd3b32ea1c84b4ef85d00c10f8 (diff)
downloadtcl-jcr_notifier_poll.zip
tcl-jcr_notifier_poll.tar.gz
tcl-jcr_notifier_poll.tar.bz2
Merge from trunkjcr_notifier_poll
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
/*