<i>TclGetProcessGlobalValue encodes information twice on Windows</i> status still Open with 4 other changes
by
.
D 2024-05-22T17:32:59.937
J comment If\sthe\shostname\son\sWindows\scontains\san\sUmlaut,\s[info\shostname]\swill\sreturn\sa\sdifferent\svalue\swhen\sinvoked\sfor\sthe\ssecond\stime:\r\n\r\n\s\s\s\s%\stclsh8.6\r\n\s\s\s\s%\sinfo\shostname\r\n\s\s\s\sfoo-läptop\r\n\s\s\s\s%\sinfo\shostname\r\n\s\s\s\sfoo-läpt\r\n\r\nBUG:\sThe\ssecond\stime,\sthe\shostname\sis\sencoded\sanother\stime.\r\n\r\nLooking\sat\sthe\scode\sfor\s[info\shostname]\son\sWindows,\sit\sseems\sto\sme:\r\n\r\n-\sinformation\sis\sstored\sin\sglobal\svariable\r\n\s\s\s\sstatic\sProcessGlobalValue\shostName\s=\r\n\s\s\s\s\t{0,\s0,\sNULL,\sNULL,\sInitializeHostName,\sNULL,\sNULL};\r\n\s\s(win/tclWinSock.c)\r\n\s\s\r\n-\sthe\sfirst\stime\sthe\sinformation\sis\sretrieved\sby\r\n\s\sTclGetProcessGlobalValue(),\sit\sis\sinitialized\sby\sa\r\n\s\scall\sto\sInitializeHostName(),\swhich\ssets\sthe\sencoding\sof\sthe\r\n\s\sinformation\sto\sutf-8\safter\sretrieving\sit\sfrom\swindows\sand\sconverting\r\n\s\sit\sto\sutf-8\r\n\s\s\s\s\s\s\s\s*encodingPtr\s=\sTcl_GetEncoding(NULL,\s"utf-8");\r\n\s\s(win/tclWinSock.c)\r\n\s\s\r\n-\sthe\snext\stime\sthe\sinformation\sis\sretrieved\sby\r\n\s\sTclGetProcessGlobalValue(),\sit\ssees\sthat\sthe\sencoding\sis\snon-NULL\sand\r\n\s\scompares\sit\sto\sthe\ssystem\sencoding,\swhich\son\sWindows\sis\snot\sutf-8,\sbut\r\n\s\s(in\smy\scase)\scp1252.\s\sSo\sthe\sinformation\sis\sconverted\sagain.\r\n\r\n\s\sTclGetProcessGlobalValue()\r\n\s\s\s\s...\r\n\s\s\s\sif\s(pgvPtr->encoding)\s{\r\n\tTcl_Encoding\scurrent\s=\sTcl_GetEncoding(NULL,\sNULL);\r\n\r\n\tif\s(pgvPtr->encoding\s!=\scurrent)\s{\r\n\r\nThis\sis\sdue\sto\sa\swrong\sfirst\sargument\sto\sTcl_UtfToExternalDString()\s\r\nin\sTclGetProcessGlobalValue()\sin\sgeneric/tclUtil.c:\r\n\r\n#4287\t\s\s\s\sTcl_UtfToExternalDString(pgvPtr->encoding,\spgvPtr->value,\r\n\t\t\s\s\s\spgvPtr->numBytes,\s&native);\r\n\r\nThe\sfirst\sargument\sis\sthe\sencoding\sto\sconvert\sTO,\snot\sconvert\sFROM.\r\n\r\nI\sfirst\sthought\sthat\sTCL9\shad\sthis\sfixed\sby\susing\sNULL\sas\sfirst\sargument,\sbut\sit\sactually\shasn't.
J icomment And\syet\sanother\sSTOP...\s:-)\r\n\r\nIt\sseems\sto\sme\sthat\sthe\sreal\sproblem\sis\ssetting\sencoding\sto\s"utf-8"\sin\sthe\sfirst\splace\sin\swin/tclWinSock.c,\sproc\sInitializeHostName().\r\n\r\nAll\sother\sinitialization\sroutines\sfor\sProcessGlobalValue\svariables\r\nuse\sNULL\sas\sencoding,\swhich\swould\swork\sas\swell\shere.\r\n\r\nSo\sin\saddition,\sthe\sfollowing\spatch\sshould\sbe\sapplied:\r\n\r\ndiff\s-u\stcl8.6.14/win/tclWinSock.c\\~\stcl8.6.14/win/tclWinSock.c\r\n---\stcl8.6.14/win/tclWinSock.c~\t2024-02-20\s18:10:06.000000000\s+0100\r\n+++\stcl8.6.14/win/tclWinSock.c\t2024-05-22\s19:31:05.113600529\s+0200\r\n@@\s-393,7\s+393,7\s@@\r\n\s\t}\r\n\s\s\s\s\s}\r\n\s\r\n-\s\s\s\s*encodingPtr\s=\sTcl_GetEncoding(NULL,\s"utf-8");\r\n+\s\s\s\s*encodingPtr\s=\sNULL;\r\n\s\s\s\s\s*lengthPtr\s=\sTcl_DStringLength(&ds);\r\n\s\s\s\s\s*valuePtr\s=\s(char\s*)ckalloc(*lengthPtr\s+\s1);\r\n\s\s\s\s\smemcpy(*valuePtr,\sTcl_DStringValue(&ds),\s*lengthPtr\s+\s1);\r\n\r\nDiff\sfinished.\s\sWed\sMay\s22\s19:31:12\s2024
J login ralfixx
J mimetype text/plain
K 3fc3287497a7e281b96661f883c20e0e74a0fca7
U ralfixx
Z 7fd01b1543de968554fb5bccf3e6ec17