1 diff -durN tcl8.3.4.orig/unix/tclUnixInit.c tcl8.3.4/unix/tclUnixInit.c
2 --- tcl8.3.4.orig/unix/tclUnixInit.c Fri Aug 24 19:13:22 2001
3 +++ tcl8.3.4/unix/tclUnixInit.c Sat Jan 11 12:39:18 2003
9 #if defined(__FreeBSD__)
10 # include <floatingpoint.h>
13 TclpSetInitialEncodings()
23 - * Determine the current encoding from the LC_* or LANG environment
24 - * variables. We previously used setlocale() to determine the locale,
25 - * but this does not work on some systems (e.g. Linux/i386 RH 5.0).
28 - langEnv = getenv("LC_ALL");
30 - if (langEnv == NULL || langEnv[0] == '\0') {
31 - langEnv = getenv("LC_CTYPE");
33 - if (langEnv == NULL || langEnv[0] == '\0') {
34 - langEnv = getenv("LANG");
36 - if (langEnv == NULL || langEnv[0] == '\0') {
41 - if (langEnv != NULL) {
42 - for (i = 0; localeTable[i].lang != NULL; i++) {
43 - if (strcmp(localeTable[i].lang, langEnv) == 0) {
44 - encoding = localeTable[i].encoding;
49 - * There was no mapping in the locale table. If there is an
50 - * encoding subfield, we can try to guess from that.
53 - if (encoding == NULL) {
55 - for (p = langEnv; *p != '\0'; p++) {
63 - Tcl_DStringInit(&ds);
64 - Tcl_DStringAppend(&ds, p, -1);
66 - encoding = Tcl_DStringValue(&ds);
67 - Tcl_UtfToLower(Tcl_DStringValue(&ds));
68 - if (Tcl_SetSystemEncoding(NULL, encoding) == TCL_OK) {
69 - Tcl_DStringFree(&ds);
72 - Tcl_DStringFree(&ds);
75 + /* read the encoding from locale settings */
76 + setlocale(LC_CTYPE, "");
77 + encoding=nl_langinfo(CODESET);
79 + /* reset the LC_CTYPE locale to "C", so ctype works for ASCII as it should */
80 + setlocale(LC_CTYPE, "C");
83 + for(i=0;i<128 && encoding[i];i++){
84 + if (i==3 && buf[0]=='i' && buf[1]=='s' && buf[2]=='o'
85 + && encoding[i]=='-') continue;
86 + buf[j++]=tolower(encoding[i]);
93 if (encoding == NULL) {
94 encoding = "iso8859-1";
96 + r=Tcl_SetSystemEncoding(NULL, encoding);
98 - Tcl_SetSystemEncoding(NULL, encoding);
100 + Tcl_SetSystemEncoding(NULL, "iso8859-1");
105 * Initialize the C library's locale subsystem. This is required
106 * for input methods to work properly on X11. We only do this for
110 setlocale(LC_CTYPE, "");
114 * In case the initial locale is not "C", ensure that the numeric
115 * processing is done in "C" locale regardless. This is needed because