Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tcl_platform(pathSeparator)

Tcl compatible.
Also move jimsh initialisation script into initjimsh.tcl

Signed-off-by: Steve Bennett <steveb@workware.net.au>
  • Loading branch information...
commit e7e3cedcbde855a2f22ee9eb830b62c45b543836 1 parent 539f52a
@msteveb authored
View
1  .gitignore
@@ -21,4 +21,5 @@ libjim.so
unicode_mapping.c
configure.gnu
load-static-exts.c
+initjimsh.c
jimsh0
View
11 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@
View
2  auto.def
@@ -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 :
}
}
View
27 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
View
4 jim.c
@@ -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 *)));
View
32 jimsh.c
@@ -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) {
View
4 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
Please sign in to comment.
Something went wrong with that request. Please try again.