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 | bc12fd68ee94dccdac5e1e6d04f160cbbad550ee (patch) | |
tree | 2c3543df68f97e1382dd5947f31e9b174b0be734 /win/tclWinSock.c | |
parent | 1c7799332924b711817436fc8940be2eff501b5c (diff) | |
download | tcl-bc12fd68ee94dccdac5e1e6d04f160cbbad550ee.zip tcl-bc12fd68ee94dccdac5e1e6d04f160cbbad550ee.tar.gz tcl-bc12fd68ee94dccdac5e1e6d04f160cbbad550ee.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; } } |