Artifacts Associated With Ticket 218663ffffffffff
Ticket change [289c86f442] (rid 88727) by nobody on 2000-10-26 01:03:51:
- assignee initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
OriginalBugID: 1636 Bug Version: 8.1b1 SubmitDate: '1999-03-25' LastModified: '1999-04-21' Severity: SER Status: Released Submitter: stanton ChangedBy: redman RelatedBugIDs: 1668 OS: All OSVersion: NA Machine: NA FixedDate: '1999-04-21' FixedInVersion: NA ClosedDate: '2000-10-25' Hi folks. I am a maintainer of Tcl/Tk Japanization patch kit (AKA tcl/tk[78]xjp). With my experience, I will report a bug of tcl8.1b1 B) I don't know exactly how many people might be stacked with this, but I think it is not few B) of course I stacked with in these environments: Linux/i386 RH 5.0 libc version 2.0.7 LANG=japanese Description: When I start tclsh, encoding is "iso-8859-1". By LANG environment variable, it should be "euc-jp". $ tclsh % encoding system iso-8859-1 % Why this happen: unix/tclUnixInit.c:TclpSetInitialEncodings() calls setlocale() and if the setlocale() fails (means that the locale is NOT supported by the system), Tcl can't find proper encoding system for language specified by user with LANG/LC_CTYPE environment variable. With my experience of making Japanization patch for Tcl/Tk 8.0x, I know that many UNIX systems can't handle locales properly EXCEPT "C" EVEN IF the systems are said as "Localized/Internationalized.". By ANSI specification, a C program MUST BE started by "C" locale until the program changes it by calling setlocale(). Thus, In original code, the locale always reset to "C" locale. If Tcl don't want (nor need) to change the currnet locale, Tcl should NOT call setlocale() ONLY to determine encoding system to be used. Because Tcl can handle MANY encoding system WITHOUT the system's locale facilities or I18N'd feature. Solution: Except calling setlocale(), Tcl should call getenv("LANG") or/and getenv("LC_CTYPE"), then compare its returned value and localeTable[]. I know this increase the I18N'd Tcl platform :) Anyway, here's patch to avoid calling setlocale(). Define -DBUGFIX in Makefile and make. Hope this patch (or code to avoid calling setlocale()) is going to be approved for users who's system can handle only "C" locale. m-hirano ------------------------------ start ------------------------------ *** ../../org/tcl8.1b1/unix/tclUnixInit.cWed Dec 2 07:40:20 1998 --- ./tclUnixInit.cSat Dec 19 02:11:50 1998 *************** *** 323,328 **** --- 323,352 ---- void TclpSetInitialEncodings() { + #ifdef BUGFIX + CONST char *encoding; + int i; + Tcl_Obj *pathPtr; + char *langEnv = getenv("LC_CTYPE"); + + if (langEnv == NULL || langEnv[0] == '\0') { + langEnv = getenv("LANG"); + } + if (langEnv == NULL || langEnv[0] == '\0') { + langEnv = NULL; + } + + encoding = "iso-8859-1"; + if (langEnv != NULL) { + for (i = 0; localeTable[i].lang != NULL; i++) { + if (strcmp(localeTable[i].lang, langEnv) == 0) { + encoding = localeTable[i].encoding; + } + } + } + + Tcl_SetSystemEncoding(NULL, encoding); + #else CONST char *locale, *encoding; int i; Tcl_Obj *pathPtr; *************** *** 361,366 **** --- 385,391 ---- Tcl_DStringFree(&ds); Tcl_SetSystemEncoding(NULL, encoding); + #endif /* BUGFIX */ /* * Until the system encoding was actually set, the library path was ------------------------------- end ------------------------------- -- [email protected] ([email protected]) Real World Computing Partnership, Tsukuba, Japan Software Research Associates, Inc., Japan Applied patch to handle detecting locale. Will follow up to see what if anything needs to be done with respect to X11R5/6. Moved description of X11 problem to 1668. 03/30/1999 14:59 - stanton - 04/21/1999 18:52 - redman - Scott S. fixed this (see above), except the X11R5/6 problem that was moved to a new Bug 1668. - foundin initialized to: "obsolete: 8.1b1"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "nobody"
- subsystem initialized to: "57. zlib"
- title initialized to: "Should NOT call setlocale() if don't want to"
- type initialized to: "Bug"
Ticket change [11c16c24a7] (rid 95199) by welch on 2000-10-26 08:26:11:
- closedate changed to: "2000-10-26T01:26:11"
- closer changed to: "welch"
- priority changed to: "2"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [10e4efde4d] (rid 95040) by dgp on 2001-04-06 03:21:22:
- closedate changed to: "2001-04-05T20:21:22"
- closer changed to: "dgp"
- subsystem changed to: "38. Init - Library - Autoload"