Overview
Comment: | Updated to use Tcl_FindExecutable() to set executable path |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 719fef74cb1a3772a89c8c94b7834513ba125676 |
User & Date: | rkeene on 2010-09-26 04:45:48 |
Other Links: | manifest | tags |
Context
2010-09-26
| ||
04:45 | Removed references to PATH_MAX check-in: 9fb1a353d1 user: rkeene tags: trunk | |
04:45 | Updated to use Tcl_FindExecutable() to set executable path check-in: 719fef74cb user: rkeene tags: trunk | |
04:45 | Updated to better locate Tclkit under Linux (partially deals with <http://code.google.com/p/tclkit/issues/detail?id=1>) check-in: bcd030ea77 user: rkeene tags: trunk | |
Changes
Modified kitsh/buildsrc/kitsh-0.0/kitInit.c from [2224f05581] to [e36e6b04a3].
32 32 #endif /* MB_TASKMODAL */ 33 33 34 34 #include "tclInt.h" 35 35 36 36 #if defined(HAVE_TCL_GETENCODINGNAMEFROMENVIRONMENT) && defined(HAVE_TCL_SETSYSTEMENCODING) 37 37 # define TCLKIT_CAN_SET_ENCODING 1 38 38 #endif 39 +#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 40 +# define TCLKIT_REQUIRE_TCLEXECUTABLENAME 1 41 +#endif 42 + 39 43 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 85 40 44 # define KIT_INCLUDES_PWB 1 41 45 #endif 42 46 #if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86 43 47 # define KIT_INCLUDES_ZLIB 1 44 48 #endif 45 49 ................................................................................ 71 75 # ifdef KIT_INCLUDES_MK4TCL 72 76 # define KIT_STORAGE_MK4 1 73 77 # else 74 78 # define KIT_STORAGE_ZIP 1 75 79 # endif 76 80 #endif 77 81 82 +#ifdef TCLKIT_REQUIRE_TCLEXECUTABLENAME 78 83 char *tclExecutableName; 84 +#endif 79 85 80 86 /* 81 87 * Attempt to load a "boot.tcl" entry from the embedded MetaKit file. 82 88 * If there isn't one, try to open a regular "setup.tcl" file instead. 83 89 * If that fails, this code will throw an error, using a message box. 84 90 */ 85 91 ................................................................................ 156 162 "set argv0 [file join [info nameofexe] main.tcl]\n" 157 163 "} else continue\n"; 158 164 159 165 /* SetExecName -- 160 166 161 167 Hack to get around Tcl bug 1224888. 162 168 */ 163 -void SetExecName(Tcl_Interp *interp) { 169 +static void SetExecName(Tcl_Interp *interp, const char *path) { 170 +#ifdef TCLKIT_REQUIRE_TCLEXECUTABLENAME 171 + tclExecutableName = strdup(path); 172 +#endif 173 + Tcl_FindExecutable(path); 174 + 175 + return; 176 +} 177 + 178 +static void FindAndSetExecName(Tcl_Interp *interp) { 179 + int len = 0; 180 + Tcl_Obj *execNameObj; 181 + Tcl_Obj *lobjv[1]; 164 182 #if defined(HAVE_READLINK) 165 - if (tclExecutableName == NULL) { 166 183 ssize_t readlink_ret; 167 184 char procpath[PATH_MAX + 1]; 168 185 char exe_buf[PATH_MAX + 1]; 169 186 int snprintf_ret; 170 187 188 + if (Tcl_GetNameOfExecutable() == NULL) { 171 189 snprintf_ret = snprintf(procpath, sizeof(procpath), "/proc/%lu/exe", (unsigned long) getpid()); 172 190 if (snprintf_ret < sizeof(procpath)) { 173 191 readlink_ret = readlink(procpath, exe_buf, sizeof(exe_buf) - 1); 174 192 175 193 if (readlink_ret > 0 && readlink_ret < (sizeof(exe_buf) - 1)) { 176 194 exe_buf[readlink_ret] = '\0'; 177 195 178 - tclExecutableName = strdup(exe_buf); 196 + SetExecName(interp, exe_buf); 179 197 180 198 return; 181 199 } 182 200 } 183 201 } 184 202 #endif 185 203 186 - if (tclExecutableName == NULL) { 187 - int len = 0; 188 - Tcl_Obj *execNameObj; 189 - Tcl_Obj *lobjv[1]; 190 - 204 + if (Tcl_GetNameOfExecutable() == NULL) { 191 205 lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY); 192 206 execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv); 193 207 194 - tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len)); 208 + SetExecName(interp, Tcl_GetStringFromObj(execNameObj, &len)); 195 209 196 210 return; 197 211 } 198 212 199 213 return; 200 214 } 201 215 ................................................................................ 243 257 Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0); 244 258 Tcl_DStringFree(&encodingName); 245 259 #endif 246 260 247 261 /* Hack to get around Tcl bug 1224888. This must be run here and 248 262 * in LibraryPathObjCmd because this information is needed both 249 263 * before and after that command is run. */ 250 - SetExecName(interp); 264 + FindAndSetExecName(interp); 251 265 252 266 TclSetPreInitScript(preInitCmd); 253 267 if (Tcl_Init(interp) == TCL_ERROR) { 254 268 goto error; 255 269 } 256 270 257 271 #ifdef KIT_INCLUDES_TK
Modified kitsh/buildsrc/kitsh-0.0/pwb.c from [5ee0d76582] to [d3bbfc6849].
21 21 { 22 22 if (objc == 1) { 23 23 Tcl_SetObjResult(interp, TclGetLibraryPath()); 24 24 } else { 25 25 Tcl_Obj *path=Tcl_DuplicateObj(objv[1]); 26 26 TclSetLibraryPath(Tcl_NewListObj(1,&path)); 27 27 TclpSetInitialEncodings(); 28 - Tcl_FindExecutable(Tcl_GetVar(interp, "argv0", TCL_GLOBAL_ONLY)); 29 - /* Hack to get around Tcl bug 1224888 */ 30 - SetExecName(interp); 31 28 } 32 29 return TCL_OK; 33 30 } 34 31 35 32 /* 36 33 * Public Entrypoint 37 34 */