summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--unix/Makefile.in35
-rw-r--r--unix/tclAppInit.c7
-rw-r--r--unix/tclUnixInit.c78
3 files changed, 100 insertions, 20 deletions
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 0992aa9..3babe19 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.24 1999/04/21 21:50:32 rjohnson Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.25 1999/05/14 02:18:31 stanton Exp $
# Current Tcl version; used in various names.
@@ -256,8 +256,8 @@ TCLSH_OBJS = tclAppInit.o
TCLTEST_OBJS = tclTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \
tclThreadTest.o tclUnixTest.o
-XTTEST_OBJS = tclTest.o tclTestObj.o tclUnixTest.o tclXtNotify.o \
- tclXtTest.o xtTestInit.o
+XTTEST_OBJS = xtTestInit.o tclTest.o tclTestObj.o tclTestProcBodyObj.o \
+ tclThreadTest.o tclUnixTest.o tclXtNotify.o tclXtTest.o
GENERIC_OBJS = regcomp.o regexec.o regfree.o regerror.o tclAlloc.o \
tclAsync.o tclBasic.o tclBinary.o \
@@ -425,12 +425,6 @@ tcltest: ${TCLTEST_OBJS} ${TCL_LIB_FILE} ${BUILD_DLTEST}
${CC} @LD_FLAGS@ ${TCLTEST_OBJS} @TCL_BUILD_LIB_SPEC@ ${LIBS} \
@TCL_LD_SEARCH_FLAGS@ -o tcltest
-xttest: ${XTTEST_OBJS} ${GENERIC_OBJS} ${UNIX_OBJS} ${COMPAT_OBJS} \
- @DL_OBJS@ ${BUILD_DLTEST}
- ${CC} ${XTTEST_OBJS} ${GENERIC_OBJS} ${UNIX_OBJS} ${COMPAT_OBJS} \
- @DL_OBJS@ @TCL_BUILD_LIB_SPEC@ ${LIBS} \
- @TCL_LD_SEARCH_FLAGS@ -lXt -o xttest
-
# Note, in the target below TCL_LIBRARY needs to be set or else
# "make test" won't work in the case where the compilation directory
@@ -652,8 +646,9 @@ xtTestInit.o: $(UNIX_DIR)/tclAppInit.c
rm -f tclAppInit.sav; \
mv tclAppInit.o tclAppInit.sav; \
fi;
- $(CC) -c $(CC_SWITCHES) -DTCL_TEST -DTCL_XT_TEST \
- $(UNIX_DIR)/tclAppInit.c
+ $(CC) -c $(CC_SWITCHES) \
+ -DTCL_BUILDTIME_LIBRARY="\"${TCL_BUILDTIME_LIBRARY}\"" \
+ -DTCL_TEST -DTCL_XT_TEST $(UNIX_DIR)/tclAppInit.c
rm -f xtTestInit.o
mv tclAppInit.o xtTestInit.o
@if test -f tclAppInit.sav ; then \
@@ -923,6 +918,24 @@ tclUnixInit.o: $(UNIX_DIR)/tclUnixInit.c $(GENERIC_DIR)/tclInitScript.h tclConfi
-DTCL_PACKAGE_PATH="\"${TCL_PACKAGE_PATH}\"" \
$(UNIX_DIR)/tclUnixInit.c
+# The following targets are not completely general. They are provide
+# purely for documentation purposes so people who are interested in
+# the Xt based notifier can modify them to suit their own installation.
+
+xttest: ${XTTEST_OBJS} ${GENERIC_OBJS} ${UNIX_OBJS} ${COMPAT_OBJS} \
+ @DL_OBJS@ ${BUILD_DLTEST}
+ ${CC} ${XTTEST_OBJS} ${GENERIC_OBJS} ${UNIX_OBJS} ${COMPAT_OBJS} \
+ @DL_OBJS@ @TCL_BUILD_LIB_SPEC@ ${LIBS} \
+ @TCL_LD_SEARCH_FLAGS@ -L/usr/openwin/lib -lXt -o xttest
+
+tclXtNotify.o: $(UNIX_DIR)/tclXtNotify.c
+ $(CC) -c $(CC_SWITCHES) -I/usr/openwin/include \
+ $(UNIX_DIR)/tclXtNotify.c
+
+tclXtTest.o: $(UNIX_DIR)/tclXtTest.c
+ $(CC) -c $(CC_SWITCHES) -I/usr/openwin/include \
+ $(UNIX_DIR)/tclXtTest.c
+
# compat binaries, these must be compiled for use in a shared library
# even though they may be placed in a static executable or library. Since
# they are included in both the tcl library and the stub library, they
diff --git a/unix/tclAppInit.c b/unix/tclAppInit.c
index b37189e..e452705 100644
--- a/unix/tclAppInit.c
+++ b/unix/tclAppInit.c
@@ -11,13 +11,9 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclAppInit.c,v 1.5 1999/04/16 00:48:03 stanton Exp $
+ * RCS: @(#) $Id: tclAppInit.c,v 1.6 1999/05/14 02:18:32 stanton Exp $
*/
-#ifdef TCL_XT_TEST
-#include <X11/Intrinsic.h>
-#endif
-
#include "tcl.h"
/*
@@ -44,6 +40,7 @@ extern int TclThread_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif /* TCL_TEST */
#ifdef TCL_XT_TEST
+extern void XtToolkitInitialize _ANSI_ARGS_((void));
extern int Tclxttest_Init _ANSI_ARGS_((Tcl_Interp *interp));
#endif
diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c
index 349b0ff..4d5f8c7 100644
--- a/unix/tclUnixInit.c
+++ b/unix/tclUnixInit.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: tclUnixInit.c,v 1.14 1999/04/21 22:00:29 stanton Exp $
+ * RCS: @(#) $Id: tclUnixInit.c,v 1.15 1999/05/14 02:18:32 stanton Exp $
*/
#include "tclInt.h"
@@ -46,6 +46,11 @@ static char defaultLibraryDir[sizeof(TCL_LIBRARY)+200] = TCL_LIBRARY;
static char pkgPath[sizeof(TCL_PACKAGE_PATH)+200] = TCL_PACKAGE_PATH;
+/*
+ * The following table is used to map from Unix locale strings to
+ * encoding files.
+ */
+
typedef struct LocaleTable {
CONST char *lang;
CONST char *encoding;
@@ -80,6 +85,10 @@ static CONST LocaleTable localeTable[] = {
{"ko_KR.eucKR", "euc-kr"},
{"korean", "euc-kr"},
+ {"ru", "iso8859-5"},
+ {"ru_RU", "iso8859-5"},
+ {"ru_SU", "iso8859-5"},
+
{"zh", "cp936"},
{NULL, NULL}
@@ -361,34 +370,94 @@ TclpSetInitialEncodings()
int i;
Tcl_Obj *pathPtr;
char *langEnv;
+ Tcl_DString ds;
/*
- * Determine the current encoding from the LC_TYPE or LANG environment
+ * Determine the current encoding from the LC_* or LANG environment
* variables. We previously used setlocale() to determine the locale,
* but this does not work on some systems (e.g. Linux/i386 RH 5.0).
*/
- langEnv = getenv("LC_CTYPE");
+ langEnv = getenv("LC_ALL");
if (langEnv == NULL || langEnv[0] == '\0') {
+ langEnv = getenv("LC_CTYPE");
+ }
+ if (langEnv == NULL || langEnv[0] == '\0') {
langEnv = getenv("LANG");
}
if (langEnv == NULL || langEnv[0] == '\0') {
langEnv = NULL;
}
- encoding = "iso8859-1";
+ encoding = NULL;
if (langEnv != NULL) {
for (i = 0; localeTable[i].lang != NULL; i++) {
if (strcmp(localeTable[i].lang, langEnv) == 0) {
encoding = localeTable[i].encoding;
+ break;
}
}
+ /*
+ * There was no mapping in the locale table. If there is an
+ * encoding subfield, we can try to guess from that.
+ */
+
+ if (encoding == NULL) {
+ char *p;
+ for (p = langEnv; *p != '\0'; p++) {
+ if (*p == '.') {
+ p++;
+ break;
+ }
+ }
+ if (*p != '\0') {
+ Tcl_DString ds;
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, p, -1);
+
+ encoding = Tcl_DStringValue(&ds);
+ Tcl_UtfToLower(Tcl_DStringValue(&ds));
+ if (Tcl_SetSystemEncoding(NULL, encoding) == TCL_OK) {
+ Tcl_DStringFree(&ds);
+ goto resetPath;
+ }
+ Tcl_DStringFree(&ds);
+ encoding = NULL;
+ }
+ }
+ }
+ if (encoding == NULL) {
+ encoding = "iso8859-1";
}
Tcl_SetSystemEncoding(NULL, encoding);
/*
+ * Initialize the C library's locale subsystem. This is required
+ * for input methods to work properly on X11. Note that we need to
+ * retore the initial "C" locale so that Tcl can parse numbers
+ * properly. The side effect of setting the default locale should be to
+ * load any locale specific modules that are needed by X.
+ */
+
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, setlocale(LC_ALL, NULL), -1);
+ setlocale(LC_ALL, "");
+ setlocale(LC_ALL, Tcl_DStringValue(&ds));
+ Tcl_DStringFree(&ds);
+
+ /*
+ * In case the initial locale is not "C", ensure that the numeric
+ * processing is done in "C" locale regardless. This is needed because
+ * Tcl relies on routines like strtod, but should not have locale
+ * dependent behavior.
+ */
+
+ setlocale(LC_NUMERIC, "C");
+
+
+ /*
* Until the system encoding was actually set, the library path was
* actually in the native multi-byte encoding, and not really UTF-8
* as advertised. We cheated as follows:
@@ -410,6 +479,7 @@ TclpSetInitialEncodings()
* encoding.
*/
+ resetPath:
pathPtr = TclGetLibraryPath();
if (pathPtr != NULL) {
int objc;