Attachment "1823552.patch" to
ticket [1823552fff]
added by
dgp
2007-11-28 03:27:27.
Index: win/tclWinSock.c
===================================================================
RCS file: /cvsroot/tcl/tcl/win/tclWinSock.c,v
retrieving revision 1.36.2.6
diff -u -r1.36.2.6 tclWinSock.c
--- win/tclWinSock.c 26 Sep 2006 21:40:37 -0000 1.36.2.6
+++ win/tclWinSock.c 27 Nov 2007 20:25:57 -0000
@@ -2550,14 +2550,25 @@
Tcl_MutexUnlock(&socketMutex);
if (TclpHasSockets(NULL) == TCL_OK) {
- /*
- * INTL: bug
- */
+ Tcl_DString ds;
- if (winSock.gethostname(hostname, sizeof(hostname)) == 0) {
+ Tcl_DStringInit(&ds);
+ Tcl_DStringSetLength(&ds, 255);
+ if (winSock.gethostname(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds))
+ == 0) {
+ Tcl_DString utfDs;
+
+ Tcl_DStringInit(&utfDs);
+ Tcl_ExternalToUtfDString(NULL, Tcl_DStringValue(&ds),
+ Tcl_DStringLength(&ds), &utfDs);
+ Tcl_DStringFree(&ds);
+
Tcl_MutexLock(&socketMutex);
+ strcpy(hostname, Tcl_DStringValue(&utfDs));
+ Tcl_UtfToLower(hostname);
hostnameInitialized = 1;
Tcl_MutexUnlock(&socketMutex);
+ Tcl_DStringFree(&utfDs);
return hostname;
}
}