From 2a9690e578778a7dfa308ed5dd03341c4f8779e6 Mon Sep 17 00:00:00 2001 From: Pat Thoyts Date: Fri, 5 Sep 2008 19:59:36 +0000 Subject: [PATCH] kitgen: improved encoding selection on startup. In 8.5+ there are new APIs to use to find out the system encoding and to select it. We can now get the system encoding set correctly provided it is actually available in the vfs. The standard channels are set to the same encoding if it can be used. git-svn-id: svn://svn.equi4.com/kitgen/trunk@4436 9e558909-932a-0410-a563-af77432da1eb --- README | 16 +++++++++++++++- config.sh | 11 +++++++---- files/boot.tcl | 10 ++++++++-- kitInit.c | 13 +++++++++++++ makefile.include | 2 +- setupvfs.tcl | 1 + 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/README b/README index d9bc32d..0c3ba1b 100644 --- a/README +++ b/README @@ -15,6 +15,9 @@ Kitgen is pronounced "kit-chen". News ---- + * 2008-09-05 : improvements in initialization of encodings + * 2008-04-11 : support for producing stardll/basekit dlls + * 2007-11-24 : support for building metakit based tclkits (old style) * 2007-05-03 : changes in cvs & build structure * 2007-04-04 : added kbs.tcl, the Kitgen Build System - see README.kbs * 2007-01-11 : fixed a vfs thread issue in boot.tcl, by Jeff Hobbs @@ -30,7 +33,15 @@ News ---- -**UPDATE, MAY 2007:** _The build notes below are no longer working. The CVS repository at equi4.com has been closed and will be replaced by an SVN mirror, hopefully by the end of May 2007. For now, you can get copies of all the important pieces at [www.equi4.com](http://www.equi4.com/pub/tk/tars/) - the latest source for the "Vlerq" extension is in "vqtcl.tgz" and the latest kitgen source is in "kitgen.tgz". See also the new [mailing list](http://groups.google.com/group/starkit) for more details._ +**UPDATE, MAY 2007:** _The build notes below are no longer working. + The CVS repository at equi4.com was replaced by a Subversion + repository. Snapshots of the necessary packages are available for + download at [www.equi4.com](http://equi4.com/pub/tk/tars) but it is + recommended to obtain current CVS or SVN checkouts of the packages. + The latest source for the "Vlerq" extension is in "vqtcl.tgz" and + the latest kitgen source is in "kitgen.tgz". See also the new + [mailing list](http://groups.google.com/group/starkit) for more + details._ ---- @@ -205,8 +216,11 @@ The remaining arguments of config.sh specify one or more build options: * `tzdata` - include the complete set of timezone data files _(8.5 only)_ * `univ` - build for both PowerPC and Intel _(Mac OS X only)_ * `x86` - build for Intel _(Mac OS X only)_ + * `mk` - build executables using Metakit instead of vlerq When not specified, the default is to build all `cli`, `dyn`, `gui` variants. +If you ask for Metakit executables then these are in addition to the vlerq +binaries. That is you will get both tclkit-cli and tclkitsh. Makefile diff --git a/config.sh b/config.sh index 6cf01aa..b8854c3 100755 --- a/config.sh +++ b/config.sh @@ -70,9 +70,13 @@ case $cli-$dyn-$gui in 0-0-0) cli=1 dyn=1 gui=1 ;; esac Linux) echo "LDFLAGS = -ldl -lm" echo "GUI_OPTS = -L/usr/X11R6/lib -lX11 -lXss" + if [ $root != "8.4" ]; then + echo "GUI_OPTS += -lXft -lXext" + fi case $b64 in 1) echo "CFLAGS += -m64" ;; esac + [ -x $upx ] && echo "UPX = $upx" ;; *BSD) @@ -101,10 +105,9 @@ case $cli-$dyn-$gui in 0-0-0) cli=1 dyn=1 gui=1 ;; esac SunOS) echo "CFLAGS += -I/usr/openwin/include" echo "LDFLAGS = -ldl -lsocket -lnsl -lm" - if [ $root = "8.5" ]; then - echo "GUI_OPTS = -L/usr/openwin/lib -L/usr/sfw/lib -lXft -lfreetype -lz -lfontconfig -lXrender -lX11 -lXext" - else - echo "GUI_OPTS = -L/usr/openwin/lib -lX11 -lXext" + echo "GUI_OPTS = -L/usr/openwin/lib -lX11 -lXext" + if [ $root != "8.4" ]; then + echo "GUI_OPTS += -L/usr/sfw/lib -lXft -lfreetype -lz -lfontconfig -lXrender" fi case $b64 in 1) echo "CFLAGS += -m64" ;; diff --git a/files/boot.tcl b/files/boot.tcl index 565f37a..d00e65d 100644 --- a/files/boot.tcl +++ b/files/boot.tcl @@ -1,7 +1,7 @@ proc tclInit {} { rename tclInit {} - global auto_path tcl_library tcl_libPath tcl_version + global auto_path tcl_library tcl_libPath tcl_version tclkit_system_encoding set noe [info nameofexecutable] @@ -84,7 +84,13 @@ proc tclInit {} { } else { encoding dirs [list [file join [info library] encoding]] ;# TIP 258 } - + # if the C code passed us a system encoding, apply it here. + if {[info exists tclkit_system_encoding]} { + # It is possible the chosen encoding is unavailable in which case + # we will be left with 'identity' to be handled below. + catch {encoding system $tclkit_system_encoding} + unset tclkit_system_encoding + } # fix system encoding, if it wasn't properly set up (200207.004 bug) if {[encoding system] eq "identity"} { switch $::tcl_platform(platform) { diff --git a/kitInit.c b/kitInit.c index 3e96a97..97d2c3a 100644 --- a/kitInit.c +++ b/kitInit.c @@ -227,6 +227,19 @@ TclKit_AppInit(Tcl_Interp *interp) Tcl_DecrRefCount(evobjPtr); } +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION > 84 + { + Tcl_DString encodingName; + Tcl_GetEncodingNameFromEnvironment(&encodingName); + if (strcmp(Tcl_DStringValue(&encodingName), Tcl_GetEncodingName(NULL))) { + /* fails, so we set a variable and do it in the boot.tcl script */ + Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName)); + } + Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0); + Tcl_DStringFree(&encodingName); + } +#endif + #ifdef KIT_DLL TclSetPreInitScript(preInitCmd); if ((Tcl_EvalEx(interp, appInitCmd, -1, TCL_EVAL_GLOBAL) == TCL_ERROR) diff --git a/makefile.include b/makefile.include index de94e59..fe0fe9e 100644 --- a/makefile.include +++ b/makefile.include @@ -58,7 +58,7 @@ kit-gui$(EXE): build/tcl build/tk build/tclvfs build/vqtcl build/zlib $(GUIOBJ) build/lib/libz$A build/lib/*tcl8*$A $(LDFLAGS) $(GUI_OPTS) build/files: - mkdir -p $@ && cd $@ && ln -s ../../../../files/* . + mkdir -p $@ && cd $@ && cp -p ../../../../files/* . build/tcl: mkdir -p $@ && cd $@ && CFLAGS="$(CFLAGS)" && export CFLAGS && \ diff --git a/setupvfs.tcl b/setupvfs.tcl index 1f9a9a2..6a36a7a 100644 --- a/setupvfs.tcl +++ b/setupvfs.tcl @@ -149,6 +149,7 @@ if {$encOpt} { lappend clifiles lib/tcl8@/encoding } else { lappend clifiles lib/tcl8@/encoding/ascii.enc \ + lib/tcl8@/encoding/cp1251.enc \ lib/tcl8@/encoding/cp1252.enc \ lib/tcl8@/encoding/iso8859-1.enc \ lib/tcl8@/encoding/iso8859-2.enc \ -- 2.23.0