Check-in [8fde0c7fbf]
Overview
Comment:Fixed test driver to call initialization routine -- changed to tclsh.

Updated to support determing encoding from environment

Removed debugging printfs/puts

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:8fde0c7fbf3fed112ce5d75afd8b09c4180cc5cf
User & Date: rkeene on 2010-09-30 05:35:48
Other Links: manifest | tags
Context
2010-09-30
05:38
Renamed test driver "tclsh" check-in: 742f8f4178 user: rkeene tags: trunk
05:35
Fixed test driver to call initialization routine -- changed to tclsh.

Updated to support determing encoding from environment

Removed debugging printfs/puts check-in: 8fde0c7fbf user: rkeene tags: trunk

2010-09-29
23:19
Updated clean target check-in: 50190b3c1d user: rkeene tags: trunk
Changes

Modified kitdll/buildsrc/kitdll-0.0/Makefile.in from [5dbeeca9bd] to [0d3b835065].

    18     18   ## Tclkit Build
    19     19   kitInit.o: kitInit.c vfs_kitdll.tcl.h
    20     20   vfs_kitdll.tcl.h: vfs_kitdll.tcl
    21     21   	./stringify.tcl vfs_kitdll.tcl > vfs_kitdll.tcl.h
    22     22   
    23     23   ## Extensions
    24     24   rechan.o: rechan.c
           25  +pwb.o: pwb.c
    25     26   
    26     27   ## DLL Build
    27         -libtcl.@SHOBJEXT@: vfs_kitdll_data_tcl.o kitInit.o rechan.o
    28         -	$(CC) $(CPPFLAGS) $(CFLAGS) -o libtcl.so vfs_kitdll_data_tcl.o kitInit.o rechan.o $(LDFLAGS) $(SHOBJLDFLAGS) -Wl,--whole-archive $(STATICLIBS) -Wl,--no-whole-archive $(LIBS)
           28  +libtcl.@SHOBJEXT@: vfs_kitdll_data_tcl.o kitInit.o rechan.o pwb.o
           29  +	$(CC) $(CPPFLAGS) $(CFLAGS) -o libtcl.so vfs_kitdll_data_tcl.o kitInit.o rechan.o pwb.o $(LDFLAGS) $(SHOBJLDFLAGS) -Wl,--whole-archive $(STATICLIBS) -Wl,--no-whole-archive $(LIBS)
    29     30   
    30     31   # Test driver
    31     32   test.o: test.c
    32     33   test: test.o
    33     34   	$(CC) $(CPPFLAGS) $(CFLAGS) -o test test.o -L. -ltcl -Wl,-R,`pwd`
    34     35   
    35     36   # Cleanup routeines

Modified kitdll/buildsrc/kitdll-0.0/boot.tcl from [72fbb06cf9] to [05bce6a79b].

     1      1   proc tclInit {} {
     2      2   	rename tclInit {}
     3      3   
     4      4   	global auto_path tcl_library tcl_libPath
     5      5   	global tcl_version tcl_rcFileName
     6      6     
     7         -	# Resolve symlinks
     8         -	set noe /.KITDLL_TCL
            7  +	# Set path where to mount VFS
            8  +	set noe "/.KITDLL_TCL"
     9      9   
    10     10   	set tcl_library [file join $noe lib tcl$tcl_version]
    11     11   	set tcl_libPath [list $tcl_library [file join $noe lib]]
    12     12   
    13     13   	# get rid of a build residue
    14     14   	unset -nocomplain ::tclDefaultLibrary
    15     15   
    16     16   	# the following code only gets executed once on startup
    17     17   	if {[info exists tcl_rcFileName]} {
    18     18   		set vfsHandler [list ::vfs::kitdll::vfshandler tcl]
    19     19   
    20         -		# mount the executable, i.e. make all runtime files available
    21         -		vfs::filesystem mount $noe $vfsHandler
    22         -
    23     20   		# alter path to find encodings
    24     21   		if {[info tclversion] eq "8.4"} {
    25         -			catch {
    26         -				load {} pwb
    27         -				librarypath [info library]
    28         -			}
           22  +			load {} pwb
           23  +			librarypath [info library]
    29     24   		} else {
    30     25   			encoding dirs [list [file join [info library] encoding]] ;# TIP 258
    31     26   		}
    32     27   
    33     28   		# fix system encoding, if it wasn't properly set up (200207.004 bug)
    34     29   		if {[encoding system] eq "identity"} {
    35     30   			if {[info exists ::tclkit_system_encoding] && $::tclkit_system_encoding != ""} {

Modified kitdll/buildsrc/kitdll-0.0/kitInit.c from [278881bf35] to [9b8845772e].

     1         -#include <stdio.h>
     2      1   #include <tcl.h>
     3      2   #include "tclInt.h"
            3  +
            4  +#if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING)
            5  +#  define TCLKIT_CAN_SET_ENCODING 1
            6  +#endif
            7  +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85
            8  +#  define KIT_INCLUDES_PWB 1
            9  +#endif
     4     10   
     5     11   Tcl_AppInitProc Vfs_Init, Rechan_Init;
     6     12   Tcl_AppInitProc Vfs_kitdll_data_tcl_Init;
           13  +#ifdef KIT_INCLUDES_PWB
           14  +Tcl_AppInitProc Pwb_Init;
           15  +#endif
     7     16   
     8     17   static char *preInitCmd =
     9     18   "proc tclKitInit {} {\n"
    10         -"puts \"Ran tclKitInit\"\n"
    11     19   	"rename tclKitInit {}\n"
           20  +	"load {} tclkit::init\n"
    12     21   	"load {} rechan\n"
    13     22   	"load {} vfs\n"
    14     23   	"load {} vfs_kitdll_data_tcl\n"
    15         -"puts \"Loaded VFS\"\n"
    16     24   #include "vfs_kitdll.tcl.h"
    17     25   	"vfs::kitdll::Mount tcl /.KITDLL_TCL\n"
    18         -"puts \"Mounted VFS\"\n"
    19     26   	"set f [open \"/.KITDLL_TCL/boot.tcl\"]\n"
    20     27   	"set s [read $f]\n"
    21     28   	"close $f\n"
           29  +	"::tclkit::init::initInterp\n"
           30  +	"rename ::tclkit::init::initInterp {}\n"
    22     31   	"uplevel #0 $s\n"
    23     32   "}\n"
    24     33   "tclKitInit";
    25     34   
    26         -void __attribute__((constructor)) _Tclkit_Init(void) {
    27         -	int tcl_ret = -1;
           35  +static int tclkit_init_initinterp(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
           36  +#ifdef _WIN32
           37  +	Tcl_SetVar(interp, "tcl_rcFileName", "~/tclkitrc.tcl", TCL_GLOBAL_ONLY);
           38  +#else   
           39  +	Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclkitrc", TCL_GLOBAL_ONLY);
           40  +#endif
           41  +
           42  +#ifdef TCLKIT_CAN_SET_ENCODING
           43  +	/* Set the encoding from the Environment */
           44  +	Tcl_GetEncodingNameFromEnvironment(&encodingName);
           45  +	Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName));
           46  +	Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
           47  +	Tcl_DStringFree(&encodingName);
           48  +#endif  
           49  +
           50  +	return(TCL_OK);
           51  +}
           52  +
           53  +int Tclkit_init_Init(Tcl_Interp *interp) {
           54  +	Tcl_Command tclCreatComm_ret;
           55  +	int tclPkgProv_ret;
           56  +
           57  +	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::tclkit::init::initInterp", tclkit_init_initinterp, NULL, NULL);
           58  +	if (!tclCreatComm_ret) {
           59  +		return(TCL_ERROR);
           60  +	}
           61  +
           62  +	tclPkgProv_ret = Tcl_PkgProvide(interp, "tclkit::init", "1.0");
           63  +
           64  +	return(tclPkgProv_ret);
           65  +}
    28     66   
           67  +void __attribute__((constructor)) _Tclkit_Init(void) {
           68  +	Tcl_StaticPackage(0, "tclkit::init", Tclkit_init_Init, NULL);
    29     69   	Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL);
    30     70   	Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL);
    31     71   	Tcl_StaticPackage(0, "vfs_kitdll_data_tcl", Vfs_kitdll_data_tcl_Init, NULL);
           72  +#ifdef KIT_INCLUDES_PWB
           73  +        Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL);
           74  +#endif  
    32     75   
    33     76   	TclSetPreInitScript(preInitCmd);
    34         -	printf("TclSetPreInitScript() = %i\n", tcl_ret);
    35     77   
    36     78   	return;
    37     79   }

Modified kitdll/buildsrc/kitdll-0.0/test.c from [ad8529fc60] to [0713d9aa46].

     1      1   #ifdef HAVE_STDIO_H
     2      2   #  include <stdio.h>
     3      3   #endif
     4      4   
     5      5   #include <tcl.h>
     6      6   
     7         -int main(int argc, char **argv) {
     8         -	Tcl_Interp *interp;
     9         -	int tcl_ret;
            7  +int Tcl_AppInit(Tcl_Interp *interp) {
            8  +	return(Tcl_Init(interp));
            9  +}
    10     10   
    11         -	interp = Tcl_CreateInterp();
    12         -	if (interp == NULL) {
    13         -		fprintf(stderr, "Unable to create an interpreter.\n");
           11  +int main(int argc, char **argv) {
           12  +	Tcl_Main(argc, argv, Tcl_AppInit);
    14     13   
    15         -		return(1);
    16         -	}
    17         -
    18         -	tcl_ret = Tcl_Init(interp);
    19         -	if (tcl_ret != TCL_OK) {
    20         -		fprintf(stderr, "Tcl_Init() returned in failure. %s\n", Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY));
    21         -
    22         -		return(1);
    23         -	}
    24         -
    25         -	tcl_ret = Tcl_Eval(interp, "puts \"Hello World. Current Time is: [clock format [clock seconds]]\"");
    26         -	if (tcl_ret != TCL_OK) {
    27         -		fprintf(stderr, "Tcl_Eval() returned in failure.\n");
    28         -
    29         -		return(1);
    30         -	}
    31         -
    32         -	Tcl_DeleteInterp(interp);
    33         -
    34         -	return(0);
           14  +	return(1);
    35     15   }