diff options
author | dgp <dgp@users.sourceforge.net> | 2007-11-27 20:30:40 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-11-27 20:30:40 (GMT) |
commit | 95b93d685d9b433814307e2283a5605002fa8362 (patch) | |
tree | 2c3543df68f97e1382dd5947f31e9b174b0be734 /win/tclWinSock.c | |
parent | 7d44c16355456cac98d296f48555468eefa6c545 (diff) | |
download | tcl-95b93d685d9b433814307e2283a5605002fa8362.zip tcl-95b93d685d9b433814307e2283a5605002fa8362.tar.gz tcl-95b93d685d9b433814307e2283a5605002fa8362.tar.bz2 |
* win/tclWinSock.c: Add missing encoding conversion of the
[info hostname] value from the system encoding to Tcl's internal
encoding. This is important now that ICANN no longer limits host
names to ASCII. [Bug 1823552]
Diffstat (limited to 'win/tclWinSock.c')
-rw-r--r-- | win/tclWinSock.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/win/tclWinSock.c b/win/tclWinSock.c index feeb374..32cfb19 100644 --- a/win/tclWinSock.c +++ b/win/tclWinSock.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinSock.c,v 1.36.2.6 2006/09/26 21:40:37 patthoyts Exp $ + * RCS: @(#) $Id: tclWinSock.c,v 1.36.2.7 2007/11/27 20:30:42 dgp Exp $ */ #include "tclWinInt.h" @@ -2550,14 +2550,25 @@ Tcl_GetHostName() 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; } } |