44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
-
+
-
+
-
-
+
|
char *
TclpFindExecutable(argv0)
CONST char *argv0; /* The value of the application's argv[0]
* (native). */
{
int length;
#ifdef __CYGWIN__
char buf[PATH_MAX * TCL_UTF_MAX + 1];
char buf[PATH_MAX * 2];
char name[PATH_MAX * TCL_UTF_MAX + 1];
#else
CONST char *name, *p;
Tcl_StatBuf statBuf;
Tcl_DString buffer, nameString;
#endif
if (tclNativeExecutableName != NULL) {
return tclNativeExecutableName;
}
#ifdef __CYGWIN__
GetModuleFileNameW(NULL, name, PATH_MAX);
GetModuleFileNameW(NULL, buf, PATH_MAX);
WideCharToMultiByte(CP_UTF8, 0, name, -1, buf, PATH_MAX, NULL, NULL);
cygwin_conv_to_full_posix_path(buf, name);
cygwin_conv_path(3, buf, name, PATH_MAX);
length = strlen(name);
if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) {
/* Strip '.exe' part. */
length -= 4;
}
tclNativeExecutableName = (char *) ckalloc(length + 1);
memcpy(tclNativeExecutableName, name, length);
|