Check-in [719fef74cb]
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
33
34
35
36
37
38




39
40
41
42
43
44
45
..
71
72
73
74
75
76
77

78

79
80
81
82
83
84
85
...
156
157
158
159
160
161
162









163



164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#endif /* MB_TASKMODAL */

#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
#if 10 * TCL_MAJOR_VERSION + TCL_MINOR_VERSION < 86
#  define KIT_INCLUDES_ZLIB 1
#endif

................................................................................
#  ifdef KIT_INCLUDES_MK4TCL
#    define KIT_STORAGE_MK4 1
#  else
#    define KIT_STORAGE_ZIP 1
#  endif
#endif


char *tclExecutableName;


    /*
     *  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.
     */

................................................................................
	"set argv0 [file join [info nameofexe] main.tcl]\n"
"} else continue\n";

/* SetExecName --

   Hack to get around Tcl bug 1224888.
*/









void SetExecName(Tcl_Interp *interp) {



#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;


		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);

				return;
			}
		}
	}
#endif

	if (tclExecutableName == NULL) {
		int len = 0;
		Tcl_Obj *execNameObj;
		Tcl_Obj *lobjv[1];

		lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY);
		execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv);

		tclExecutableName = strdup(Tcl_GetStringFromObj(execNameObj, &len));

		return;
	}

	return;
}

................................................................................
	Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
	Tcl_DStringFree(&encodingName);
#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);

	TclSetPreInitScript(preInitCmd);
	if (Tcl_Init(interp) == TCL_ERROR) {
		goto error;
	}

#ifdef KIT_INCLUDES_TK







>
>
>
>







 







>

>







 







>
>
>
>
>
>
>
>
>
|
>
>
>

<





>







|







|
<
<
<
<



|







 







|







32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
..
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
...
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182

183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204




205
206
207
208
209
210
211
212
213
214
215
...
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#endif /* MB_TASKMODAL */

#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
#endif

................................................................................
#  ifdef KIT_INCLUDES_MK4TCL
#    define KIT_STORAGE_MK4 1
#  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.
     */

................................................................................
	"set argv0 [file join [info nameofexe] main.tcl]\n"
"} else continue\n";

/* SetExecName --

   Hack to get around Tcl bug 1224888.
*/
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)

	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';

				SetExecName(interp, exe_buf);

				return;
			}
		}
	}
#endif

	if (Tcl_GetNameOfExecutable() == NULL) {




		lobjv[0] = Tcl_GetVar2Ex(interp, "argv0", NULL, TCL_GLOBAL_ONLY);
		execNameObj = Tcl_FSJoinToPath(Tcl_FSGetCwd(interp), 1, lobjv);

		SetExecName(interp, Tcl_GetStringFromObj(execNameObj, &len));

		return;
	}

	return;
}

................................................................................
	Tcl_SetVar(interp, "tclkit_system_encoding", Tcl_DStringValue(&encodingName), 0);
	Tcl_DStringFree(&encodingName);
#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. */
	FindAndSetExecName(interp);

	TclSetPreInitScript(preInitCmd);
	if (Tcl_Init(interp) == TCL_ERROR) {
		goto error;
	}

#ifdef KIT_INCLUDES_TK

Modified kitsh/buildsrc/kitsh-0.0/pwb.c from [5ee0d76582] to [d3bbfc6849].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
{
     if (objc == 1) {
	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;
}

/*
 * Public Entrypoint
 */







<
<
<







21
22
23
24
25
26
27



28
29
30
31
32
33
34
{
     if (objc == 1) {
	Tcl_SetObjResult(interp, TclGetLibraryPath());
     } else {
	Tcl_Obj *path=Tcl_DuplicateObj(objv[1]);
	TclSetLibraryPath(Tcl_NewListObj(1,&path));
	TclpSetInitialEncodings();



     }
     return TCL_OK;
}

/*
 * Public Entrypoint
 */