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
19
20
21
22
23
24

25
26
27
28


29
30
31
32
33
34
35
18
19
20
21
22
23
24
25
26
27


28
29
30
31
32
33
34
35
36







+


-
-
+
+







## Tclkit Build
kitInit.o: kitInit.c vfs_kitdll.tcl.h
vfs_kitdll.tcl.h: vfs_kitdll.tcl
	./stringify.tcl vfs_kitdll.tcl > vfs_kitdll.tcl.h

## Extensions
rechan.o: rechan.c
pwb.o: pwb.c

## DLL Build
libtcl.@SHOBJEXT@: vfs_kitdll_data_tcl.o kitInit.o rechan.o
	$(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)
libtcl.@SHOBJEXT@: vfs_kitdll_data_tcl.o kitInit.o rechan.o pwb.o
	$(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)

# Test driver
test.o: test.c
test: test.o
	$(CC) $(CPPFLAGS) $(CFLAGS) -o test test.o -L. -ltcl -Wl,-R,`pwd`

# Cleanup routeines

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

1
2
3
4
5
6
7
8


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27


28
29
30
31
32
33
34
35
1
2
3
4
5
6


7
8
9
10
11
12
13
14
15
16
17
18
19



20
21



22
23

24
25
26
27
28
29
30






-
-
+
+











-
-
-


-
-
-
+
+
-







proc tclInit {} {
	rename tclInit {}

	global auto_path tcl_library tcl_libPath
	global tcl_version tcl_rcFileName
  
	# Resolve symlinks
	set noe /.KITDLL_TCL
	# Set path where to mount VFS
	set noe "/.KITDLL_TCL"

	set tcl_library [file join $noe lib tcl$tcl_version]
	set tcl_libPath [list $tcl_library [file join $noe lib]]

	# get rid of a build residue
	unset -nocomplain ::tclDefaultLibrary

	# the following code only gets executed once on startup
	if {[info exists tcl_rcFileName]} {
		set vfsHandler [list ::vfs::kitdll::vfshandler tcl]

		# mount the executable, i.e. make all runtime files available
		vfs::filesystem mount $noe $vfsHandler

		# alter path to find encodings
		if {[info tclversion] eq "8.4"} {
			catch {
				load {} pwb
				librarypath [info library]
			load {} pwb
			librarypath [info library]
			}
		} else {
			encoding dirs [list [file join [info library] encoding]] ;# TIP 258
		}

		# fix system encoding, if it wasn't properly set up (200207.004 bug)
		if {[encoding system] eq "identity"} {
			if {[info exists ::tclkit_system_encoding] && $::tclkit_system_encoding != ""} {

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

1
2
3







4
5
6



7
8
9
10
11

12
13
14
15
16
17
18
19
20
21


22
23
24
25






26
27















28












29
30
31



32
33
34
35
36
37

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

19
20
21
22
23

24
25

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

77
78
79
-


+
+
+
+
+
+
+



+
+
+



-

+



-


-



+
+




+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
+
+
+
+
+
+
+



+
+
+


-



#include <stdio.h>
#include <tcl.h>
#include "tclInt.h"

#if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING)
#  define TCLKIT_CAN_SET_ENCODING 1
#endif
#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85
#  define KIT_INCLUDES_PWB 1
#endif

Tcl_AppInitProc Vfs_Init, Rechan_Init;
Tcl_AppInitProc Vfs_kitdll_data_tcl_Init;
#ifdef KIT_INCLUDES_PWB
Tcl_AppInitProc Pwb_Init;
#endif

static char *preInitCmd =
"proc tclKitInit {} {\n"
"puts \"Ran tclKitInit\"\n"
	"rename tclKitInit {}\n"
	"load {} tclkit::init\n"
	"load {} rechan\n"
	"load {} vfs\n"
	"load {} vfs_kitdll_data_tcl\n"
"puts \"Loaded VFS\"\n"
#include "vfs_kitdll.tcl.h"
	"vfs::kitdll::Mount tcl /.KITDLL_TCL\n"
"puts \"Mounted VFS\"\n"
	"set f [open \"/.KITDLL_TCL/boot.tcl\"]\n"
	"set s [read $f]\n"
	"close $f\n"
	"::tclkit::init::initInterp\n"
	"rename ::tclkit::init::initInterp {}\n"
	"uplevel #0 $s\n"
"}\n"
"tclKitInit";

static int tclkit_init_initinterp(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
#ifdef _WIN32
	Tcl_SetVar(interp, "tcl_rcFileName", "~/tclkitrc.tcl", TCL_GLOBAL_ONLY);
#else   
	Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclkitrc", TCL_GLOBAL_ONLY);
#endif
void __attribute__((constructor)) _Tclkit_Init(void) {
	int tcl_ret = -1;

#ifdef TCLKIT_CAN_SET_ENCODING
	/* Set the encoding from the Environment */
	Tcl_GetEncodingNameFromEnvironment(&encodingName);
	Tcl_SetSystemEncoding(NULL, Tcl_DStringValue(&encodingName));
	Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
	Tcl_DStringFree(&encodingName);
#endif  

	return(TCL_OK);
}

int Tclkit_init_Init(Tcl_Interp *interp) {
	Tcl_Command tclCreatComm_ret;
	int tclPkgProv_ret;

	tclCreatComm_ret = Tcl_CreateObjCommand(interp, "::tclkit::init::initInterp", tclkit_init_initinterp, NULL, NULL);
	if (!tclCreatComm_ret) {
		return(TCL_ERROR);
	}

	tclPkgProv_ret = Tcl_PkgProvide(interp, "tclkit::init", "1.0");

	return(tclPkgProv_ret);
}

void __attribute__((constructor)) _Tclkit_Init(void) {
	Tcl_StaticPackage(0, "tclkit::init", Tclkit_init_Init, NULL);
	Tcl_StaticPackage(0, "rechan", Rechan_Init, NULL);
	Tcl_StaticPackage(0, "vfs", Vfs_Init, NULL);
	Tcl_StaticPackage(0, "vfs_kitdll_data_tcl", Vfs_kitdll_data_tcl_Init, NULL);
#ifdef KIT_INCLUDES_PWB
        Tcl_StaticPackage(0, "pwb", Pwb_Init, NULL);
#endif  

	TclSetPreInitScript(preInitCmd);
	printf("TclSetPreInitScript() = %i\n", tcl_ret);

	return;
}

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

1
2
3
4
5
6
7
8

9
10
11
12
13
14
15
16


17
18
19
20
21

22
23
24

25
26
27
28
29

30
31
32
33
34
35
1
2
3
4
5
6


7








8
9
10




11



12



13

14





15






-
-
+
-
-
-
-
-
-
-
-
+
+

-
-
-
-
+
-
-
-
+
-
-
-

-
+
-
-
-
-
-

#ifdef HAVE_STDIO_H
#  include <stdio.h>
#endif

#include <tcl.h>

int main(int argc, char **argv) {
	Tcl_Interp *interp;
int Tcl_AppInit(Tcl_Interp *interp) {
	int tcl_ret;

	interp = Tcl_CreateInterp();
	if (interp == NULL) {
		fprintf(stderr, "Unable to create an interpreter.\n");

		return(1);
	}
	return(Tcl_Init(interp));
}

	tcl_ret = Tcl_Init(interp);
	if (tcl_ret != TCL_OK) {
		fprintf(stderr, "Tcl_Init() returned in failure. %s\n", Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY));

int main(int argc, char **argv) {
		return(1);
	}

	Tcl_Main(argc, argv, Tcl_AppInit);
	tcl_ret = Tcl_Eval(interp, "puts \"Hello World. Current Time is: [clock format [clock seconds]]\"");
	if (tcl_ret != TCL_OK) {
		fprintf(stderr, "Tcl_Eval() returned in failure.\n");

		return(1);
	return(1);
	}

	Tcl_DeleteInterp(interp);

	return(0);
}