Index: kitsh/buildsrc/kitsh-0.0/kitInit.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/kitInit.c +++ kitsh/buildsrc/kitsh-0.0/kitInit.c @@ -34,10 +34,14 @@ #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 TCLKIT_REQUIRE_TCLEXECUTABLENAME 1 +#endif + #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 # define KIT_INCLUDES_PWB 1 #endif #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 # define KIT_INCLUDES_ZLIB 1 @@ -73,11 +77,13 @@ # else # define KIT_STORAGE_ZIP 1 # endif #endif +#ifdef TCLKIT_REQUIRE_TCLEXECUTABLENAME char *tclExecutableName; +#endif /* * Attempt to load a "boot.tcl" entry from the embedded MetaKit file. * If there isn't one, try to open a regular "setup.tcl" file instead. * If that fails, this code will throw an error, using a message box. @@ -158,42 +164,50 @@ /* SetExecName -- Hack to get around Tcl bug 1224888. */ -void SetExecName(Tcl_Interp *interp) { +static void SetExecName(Tcl_Interp *interp, const char *path) { +#ifdef TCLKIT_REQUIRE_TCLEXECUTABLENAME + tclExecutableName = strdup(path); +#endif + Tcl_FindExecutable(path); + + return; +} + +static void FindAndSetExecName(Tcl_Interp *interp) { + int len = 0; + Tcl_Obj *execNameObj; + Tcl_Obj *lobjv[1]; #if defined(HAVE_READLINK) - if (tclExecutableName == NULL) { - ssize_t readlink_ret; - char procpath[PATH_MAX + 1]; - char exe_buf[PATH_MAX + 1]; - int snprintf_ret; + ssize_t readlink_ret; + char procpath[PATH_MAX + 1]; + char exe_buf[PATH_MAX + 1]; + int snprintf_ret; + if (Tcl_GetNameOfExecutable() == NULL) { snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid()); if (snprintf_ret < sizeof(procpath)) { readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1); if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) { exe_buf[readlink_ret] = '\0'; - tclExecutableName = strdup(exe_buf); + SetExecName(interp, exe_buf); return; } } } #endif - if (tclExecutableName == NULL) { - int len = 0; - Tcl_Obj *execNameObj; - Tcl_Obj *lobjv[1]; - + if (Tcl_GetNameOfExecutable() == NULL) { lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv); - tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len)); + SetExecName(interp, Tcl_GetStringFromObj(execNameObj, &len)); return; } return; @@ -245,11 +259,11 @@ #endif /* Hack to get around Tcl bug 1224888. This must be run here and * in LibraryPathObjCmd because this information is needed both * before and after that command is run. */ - SetExecName(interp); + FindAndSetExecName(interp); TclSetPreInitScript(preInitCmd); if (Tcl_Init(interp) == TCL_ERROR) { goto error; } Index: kitsh/buildsrc/kitsh-0.0/pwb.c ================================================================== --- kitsh/buildsrc/kitsh-0.0/pwb.c +++ kitsh/buildsrc/kitsh-0.0/pwb.c @@ -23,13 +23,10 @@ Tcl_SetObjResult(interp, TclGetLibraryPath()); } else { Tcl_Obj *path=Tcl_DuplicateObj(objv[1]); TclSetLibraryPath(Tcl_NewListObj(1,&path)); TclpSetInitialEncodings(); - Tcl_FindExecutable(Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY)); - /* Hack to get around Tcl bug 1224888 */ - SetExecName(interp); } return TCL_OK; } /*