.
D 2004-12-11T04:24:19
J icomment Logged\sIn:\sYES\s\nuser_id=80530\n\n\nIn\sTcl\s8.5a2,\sTcl_FindExecutable()\nand\sits\scomponents\sgot\sa\ssubstantial\nrewrite.\s\sThe\sbody\sof\sT_FE\snow\nclearly\sshow\sthe\svarious\sthings\sit\sdoes:\n{\n\s\s\s\sTclInitSubsystems();\n\s\s\s\sTclpSetInitialEncodings();\n\s\s\s\sTclpFindExecutable(argv0);\n}\n\nThe\sTclInitSubsystems()\scall\s\nrepresents\sthe\sfundamental\sinitialization\nof\sthe\sTcl\slibrary.\s\sWithout\sthis\scall\scoming\nfirst,\smany\sof\sthe\sroutines\s(even\spublic\sones)\nof\sthe\sTcl\slibrary\swill\sfail\sor\seven\scrash.\n\nCurrently\sthere\sare\stwo\spublic\sroutines\nthat\sin\sturn\scall\sTclInitSubsystems,\nTcl_FindExecutable()\sand\sTcl_CreateInterp().\nAny\scode\smaking\scalls\sinto\sthe\sTcl\slibrary\nshould\sbe\swritten\sso\sthat\sits\sknow\sone\sof\sthese\nroutines\shas\sbeen\scalled\sfirst.\n\nIt\smay\sbe\sto\sour\sadvantage\sto\smake\nTclInitSubsystems()\sitself\sa\spublic\nroutine\s(with\sthe\sname\sTcl_Initialize()\s?)\nso\sthat\sthe\sresponsibilities\sof\scallers\nare\seasier\sto\sdescribe\s(call\sTcl_Initialize()\nfirst;\scall\sTcl_Finalize()\swhen\sthe\slibrary\nwon't\sbe\scalled\sanymore).\n\nAfter\sTclInitSubsystems()\sreturns,\sall\nof\sTcl's\spublic\sroutines\sshould\sbe\n"crash\ssafe"\swhen\scalled\saccording\sto\ntheir\sdocumentation.\n\nTclpSetInitialEncodings\smakes\san\nattempt\sto\sinitialize\s[encoding\ssystem]\naccording\sto\sthe\senvironment\sof\sthe\nprocess.\s\sIts\simplementation\sis:\n{\n\s\s\s\sTcl_DString\sencodingName;\n\s\s\s\sTcl_SetSystemEncoding(NULL,\n\s\s\s\s\s\s\s\s\s\s\s\sTclpGetEncodingNameFromEnvironment(&encodingName));\n\s\s\s\sTcl_DStringFree(&encodingName);\n}\n\nTclpSetInitialEncodings()\smight\ncorrectly\sinitialize\s[encoding\ssystem],\nor\sit\smight\snot.\s\sWhen\sit\scannot,\sit\swill\nleave\s[encoding\ssystem]\swith\sthe\svalue\nof\s"identity".\s\sTclkit\swill\sface\sthis\ssituation,\nbecause\sat\sthe\stime\sTcl_FindExecutable\nis\scalled,\sthe\s*.enc\sfiles\swill\snot\sbe\sfound\non\sthe\sencoding\ssearch\spath\syet.\n\nWe\sshould\smake\nTclpGetEncodingNameFromEnvironment()\na\spublic\sroutine\sso\sthat\scallers\sof\sthe\nTcl\slibrary\scan\scheck\sat\sany\stime\swhether\nthe\svalue\sof\s[encoding\ssystem]\sagrees\nwith\swhat\sTcl\sthinks\sthe\senvironment\nexpects\sit\sto\sbe.\s\sWith\sthat\sroutine\spublic,\nTclkit\scan\seasily\srepeat\sthe\s[encoding\ssystem]\ninitialization\sattempt\safter\sit\sis\ssatisfied\sthat\na\sproper\sencoding\ssearch\spath\sis\sin\splace.\n\nFinally,\sTclpFindExecutable()\sperforms\nthe\sfunction\sof\sinitializing\s[info\snameofexecutable].\nThe\svalue\sis\sstored\sas\sa\sProcessGlobalValue\n-\sa\snew\skid\sof\sstruct\sin\sthe\sTcl\slibrary\s-\sthat\sautomatically\nadapts\sitself\sto\sany\schanges\sin\s[encoding\ssystem].\n\nWith\sTcl\s8.4,\sTclkit's\sLibraryPathObjCmd\shad\sto\nmake\sa\ssecond\scall\sto\sTcl_FindExecutable\sto\nreset\sthe\sproper\sencoding\sfor\sthe\s[info\snoe]\svalue.\nThat\sis\sno\slonger\srequired,\sand\sin\sfact\scauses\sa\nproblem.\n\nStartup\ssequence\srecommendation\sfor\sTclkit\nis\snow:\n\n\s\s\s\sTclInitSubsystems();\n\s\s\s\sTclSetEncodingSearchPath(Tcl_NewObj());\n\s\s\s\sTcl_Main(...)\n\nand\swithin\sLibraryPathObjCmd():\n\n\s\s\s\sTcl_DString\sencodingName;\n\s\s\s\sTclSetEncodingSearchPath(objv[1]);\n\s\s\s\sTcl_SetSystemEncoding(NULL,\n\s\s\s\s\s\s\s\s\s\s\s\sTclpGetEncodingNameFromEnvironment(&encodingName));\n\s\s\s\sTcl_DStringFree(&encodingName);\n\nand\swithin\sboot.tcl:\n\n\s\s\s\slibraryPath\s[file\sjoin\s[info\slibrary]\sencoding]\n\nAdditional\scosmetic\schange\smight\sbe\sto\srename\n[libraryPath]\sto\s[encodingPath]\ssince\sthat's\swhat's\nreally\sbeing\sset.\n\nTcl\sshould\sexpose\sa\sscript\slevel\scommand\sto\sallow\nsetting\sof\sthe\sencoding\ssearch\spath.\s\sThat\smight\nlead\sto\sa\sline\sin\sboot.tcl\ssomething\slike:\n\n\s\s\s\sencoding\sdirs\s[file\sjoin\s[info\slibrary]\sencoding]\n\nA\sre-attempt\sto\sset\s[encoding\ssystem]\swould\sthen\nbe\sneeded,\sand\sthat\smight\smean\sexposing\s\nTclpGetEncodingNameFromEnvironment\sat\nthe\sscript\slevel\sas\swell.\n\nI\sthink\sworking\ssource\scode\schanges\sfor\sTclkit\s8.5a2\nhave\sbeen\sfed\sback\snow.\s\sComments\son\scontinuing\nplans\sare\sinvited.\n\n
J login dgp
J mimetype text/plain
J username dgp
K 579617ffffffffffffffffffffffffffffffffff
U dgp
Z 9ba909c38a1bc77889e99c838e81fba3