diff options
author | dgp <dgp@users.sourceforge.net> | 2012-05-24 16:50:40 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2012-05-24 16:50:40 (GMT) |
commit | 286580c577c4f54efd199d0996a7df88c02d01b4 (patch) | |
tree | 4251a9956293cba5d933f821e66ea739b15f7dca /unix/tclUnixFile.c | |
parent | c8619c8ec837fc2b74af6a04df85b7c5646fae5d (diff) | |
parent | dce46c947bd11b68d1979b9e708d177acfddb911 (diff) | |
download | tcl-286580c577c4f54efd199d0996a7df88c02d01b4.zip tcl-286580c577c4f54efd199d0996a7df88c02d01b4.tar.gz tcl-286580c577c4f54efd199d0996a7df88c02d01b4.tar.bz2 |
merge 8.5
Diffstat (limited to 'unix/tclUnixFile.c')
-rw-r--r-- | unix/tclUnixFile.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c index 7d82d1d..edd0d2f 100644 --- a/unix/tclUnixFile.c +++ b/unix/tclUnixFile.c @@ -22,7 +22,8 @@ static int NativeMatchType(Tcl_Interp *interp, CONST char* nativeEntry, * TclpFindExecutable -- * * This function computes the absolute path name of the current - * application, given its argv[0] value. + * application, given its argv[0] value. For Cygwin, argv[0] is + * ignored and the path is determined the same as under win32. * * Results: * None. @@ -38,10 +39,26 @@ TclpFindExecutable( CONST char *argv0) /* The value of the application's argv[0] * (native). */ { - CONST char *name, *p; + Tcl_Encoding encoding; +#ifdef __CYGWIN__ + int length; + char buf[PATH_MAX * TCL_UTF_MAX + 1]; + char name[PATH_MAX * TCL_UTF_MAX + 1]; + GetModuleFileNameW(NULL, name, PATH_MAX); + WideCharToMultiByte(CP_UTF8, 0, name, -1, buf, PATH_MAX, NULL, NULL); + cygwin_conv_to_full_posix_path(buf, name); + length = strlen(name); + if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) { + /* Strip '.exe' part. */ + length -= 4; + } + encoding = Tcl_GetEncoding(NULL, NULL); + TclSetObjNameOfExecutable( + Tcl_NewStringObj(name, length), encoding); +#else + const char *name, *p; Tcl_StatBuf statBuf; Tcl_DString buffer, nameString, cwd, utfName; - Tcl_Encoding encoding; if (argv0 == NULL) { return; @@ -174,6 +191,7 @@ TclpFindExecutable( done: Tcl_DStringFree(&buffer); +#endif } /* |