diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.in | 11 | ||||
-rw-r--r-- | auto.def | 2 | ||||
-rw-r--r-- | initjimsh.tcl | 27 | ||||
-rw-r--r-- | jim.c | 4 | ||||
-rw-r--r-- | jimsh.c | 32 | ||||
-rwxr-xr-x | make-bootstrap-jim | 4 |
7 files changed, 47 insertions, 34 deletions
@@ -21,4 +21,5 @@ libjim.so unicode_mapping.c configure.gnu load-static-exts.c +initjimsh.c jimsh0 diff --git a/Makefile.in b/Makefile.in index 80ea37f..0f0d1d2 100644 --- a/Makefile.in +++ b/Makefile.in @@ -44,16 +44,19 @@ EXTENSION_TCL := $(patsubst %,%.tcl,@JIM_TCL_EXTENSIONS@) .PRECIOUS: jim-%.c +all: $(JIMSH) $(EXTENSION_MODS) + # Create C extensions from pure Tcl extensions jim-%.c: %.tcl @tclsh@ @srcdir@/make-c-ext.tcl $< >$@ || ( rm $@; exit 1) -all: $(JIMSH) $(EXTENSION_MODS) +initjimsh.c: initjimsh.tcl + @tclsh@ @srcdir@/make-c-ext.tcl $< >$@ || ( rm $@; exit 1) docs: Tcl.html -$(JIMSH): $(LIBJIM) jimsh.o - $(CC) $(CFLAGS) @SH_LINKFLAGS@ $(LDFLAGS) -o $@ jimsh.o $(LIBJIM) $(LDLIBS) +$(JIMSH): $(LIBJIM) jimsh.o initjimsh.o + $(CC) $(CFLAGS) @SH_LINKFLAGS@ $(LDFLAGS) -o $@ jimsh.o initjimsh.o $(LIBJIM) $(LDLIBS) install: all docs $(EXTENSION_TCL) install-exec mkdir -p $(DESTDIR)$(prefix)/lib/jim @@ -110,7 +113,7 @@ Tcl.html: jim_tcl.txt @tclsh@ @srcdir@/make-index $^ | asciidoc -o $@ -d manpage - || cp @srcdir@/Tcl_shipped.html Tcl.html clean: - rm -f *.o *.so lib*.a $(JIMSH) Tcl.html unicode_mapping.c load-static-exts.c @GENERATED_SRCS@ + rm -f *.o *.so lib*.a $(JIMSH) Tcl.html unicode_mapping.c load-static-exts.c initjimsh.c @GENERATED_SRCS@ distclean: clean rm -f jimautoconf.h jim-config.h Makefile config.log autosetup/jimsh0@EXEEXT@ @@ -79,11 +79,13 @@ switch -glob -- $host_os { define-feature dlopen-compat define TCL_PLATFORM_OS $host_os define TCL_PLATFORM_PLATFORM windows + define TCL_PLATFORM_PATH_SEPARATOR {;} } default { # Note that cygwin is considered a unix platform define TCL_PLATFORM_OS $host_os define TCL_PLATFORM_PLATFORM unix + define TCL_PLATFORM_PATH_SEPARATOR : } } diff --git a/initjimsh.tcl b/initjimsh.tcl new file mode 100644 index 0000000..a764f3a --- /dev/null +++ b/initjimsh.tcl @@ -0,0 +1,27 @@ +# This pseudo-package is loaded from jimsh to add additional +# paths to $auto_path and to source ~/.jimrc + +proc _jimsh_init {} { + rename _jimsh_init {} + + # Add to the standard auto_path + lappend p {*}[split [env JIMLIB {}] $::tcl_platform(pathSeparator)] + lappend p {*}$::auto_path + lappend p [file dirname [info nameofexecutable]] + set ::auto_path $p + + if {$::tcl_interactive && [env HOME {}] ne ""} { + foreach src {.jimrc jimrc.tcl} { + if {[file exists [env HOME]/$src]} { + uplevel #0 source [env HOME]/$src + break + } + } + } +} + +if {$tcl_platform(platform) eq "windows"} { + set jim_argv0 [string map {\\ /} $jim_argv0] +} + +_jimsh_init @@ -85,6 +85,9 @@ #ifndef TCL_PLATFORM_PLATFORM #define TCL_PLATFORM_PLATFORM "unknown" #endif +#ifndef TCL_PLATFORM_PATH_SEPARATOR +#define TCL_PLATFORM_PATH_SEPARATOR ":" +#endif /*#define DEBUG_SHOW_SCRIPT*/ /*#define DEBUG_SHOW_SCRIPT_TOKENS*/ @@ -4991,6 +4994,7 @@ Jim_Interp *Jim_CreateInterp(void) Jim_SetVariableStrWithStr(i, "tcl_platform(os)", TCL_PLATFORM_OS); Jim_SetVariableStrWithStr(i, "tcl_platform(platform)", TCL_PLATFORM_PLATFORM); + Jim_SetVariableStrWithStr(i, "tcl_platform(pathSeparator)", TCL_PLATFORM_PATH_SEPARATOR); Jim_SetVariableStrWithStr(i, "tcl_platform(byteOrder)", JimIsBigEndian() ? "bigEndian" : "littleEndian"); Jim_SetVariableStrWithStr(i, "tcl_platform(threaded)", "0"); Jim_SetVariableStr(i, "tcl_platform(pointerSize)", Jim_NewIntObj(i, sizeof(void *))); @@ -26,34 +26,8 @@ #include "jim.h" #include "jimautoconf.h" -/* Script to help initialise jimsh */ -static const char jimsh_init[] = \ -"proc _init {} {\n" -"\trename _init {}\n" -/* XXX This is a big ugly */ -#if defined(__MINGW32__) -"\tlappend p {*}[split [env JIMLIB {}] {;}]\n" -#else -"\tlappend p {*}[split [env JIMLIB {}] :]\n" -#endif -"\tlappend p {*}$::auto_path\n" -"\tlappend p [file dirname [info nameofexecutable]]\n" -"\tset ::auto_path $p\n" -"\n" -"\tif {$::tcl_interactive && [env HOME {}] ne \"\"} {\n" -"\t\tforeach src {.jimrc jimrc.tcl} {\n" -"\t\t\tif {[file exists [env HOME]/$src]} {\n" -"\t\t\t\tuplevel #0 source [env HOME]/$src\n" -"\t\t\t\tbreak\n" -"\t\t\t}\n" -"\t\t}\n" -"\t}\n" -"}\n" -/* XXX This is a big ugly */ -#if defined(__MINGW32__) -"set jim_argv0 [string map {\\\\ /} $jim_argv0]\n" -#endif -"_init\n"; +/* From initjimsh.tcl */ +extern int Jim_initjimshInit(Jim_Interp *interp); static void JimSetArgv(Jim_Interp *interp, int argc, char *const argv[]) { @@ -93,7 +67,7 @@ int main(int argc, char *const argv[]) Jim_SetVariableStrWithStr(interp, "jim_argv0", argv[0]); Jim_SetVariableStrWithStr(interp, JIM_INTERACTIVE, argc == 1 ? "1" : "0"); - retcode = Jim_Eval(interp, jimsh_init); + retcode = Jim_initjimshInit(interp); if (argc == 1) { if (retcode == JIM_ERR) { diff --git a/make-bootstrap-jim b/make-bootstrap-jim index a7b81b2..2d8595f 100755 --- a/make-bootstrap-jim +++ b/make-bootstrap-jim @@ -40,7 +40,7 @@ EOF } cexts="aio readdir regexp file exec clock array" -tclexts="bootstrap glob stdlib tclcompat" +tclexts="bootstrap initjimsh glob stdlib tclcompat" # Note ordering allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompat" @@ -62,11 +62,13 @@ cat <<EOF #if defined(__MINGW32__) #define TCL_PLATFORM_OS "mingw" #define TCL_PLATFORM_PLATFORM "windows" +#define TCL_PLATFORM_PATH_SEPARATOR ";" #define HAVE_MKDIR_ONE_ARG #define HAVE_SYSTEM #else #define TCL_PLATFORM_OS "unknown" #define TCL_PLATFORM_PLATFORM "unix" +#define TCL_PLATFORM_PATH_SEPARATOR ":" #define HAVE_VFORK #define HAVE_WAITPID #endif |