28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
+
+
+
+
+
+
+
+
+
+
+
|
#endif /* _WIN32 */
#ifndef MB_TASKMODAL
# define MB_TASKMODAL 0
#endif /* MB_TASKMODAL */
#include "tclInt.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_DLADDR
# ifdef HAVE_DLFCN_H
# include <dlfcn.h>
# else
# undef HAVE_DLADDR
# endif
#endif
#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
|
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
216
217
218
219
220
221
222
223
224
225
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
return;
}
static void FindAndSetExecName(Tcl_Interp *interp) {
int len = 0;
Tcl_Obj *execNameObj;
Tcl_Obj *lobjv[1];
#if defined(HAVE_READLINK)
#ifdef HAVE_READLINK
ssize_t readlink_ret;
char procpath[4096];
char exe_buf[4096];
int snprintf_ret;
#endif /* HAVE_READLINK */
#ifdef HAVE_DLADDR
Dl_info syminfo;
int dladdr_ret;
#endif /* HAVE_DLADDR */
#ifdef HAVE_READLINK
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 /* HAVE_READLINK */
#ifdef HAVE_DLADDR
if (Tcl_GetNameOfExecutable() == NULL) {
dladdr_ret = dladdr(&SetExecName, &syminfo);
if (dladdr_ret != 0) {
SetExecName(interp, syminfo.dli_fname);
}
}
#endif
#endif /* HAVE_DLADDR */
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));
|