summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclZipfs.c21
-rw-r--r--unix/Makefile.in1
-rw-r--r--unix/tclUnixFile.c4
-rw-r--r--unix/tclUnixPort.h2
-rw-r--r--win/tclWinFile.c2
-rw-r--r--win/tclWinInit.c8
6 files changed, 17 insertions, 21 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index f052c2e..b45bdfe 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -3104,16 +3104,13 @@ ZipFSListObjCmd(
*-------------------------------------------------------------------------
*/
-#ifdef _WIN32
-#define LIBRARY_SIZE 64
-#endif /* _WIN32 */
-
Tcl_Obj *
TclZipfs_TclLibrary(void)
{
Tcl_Obj *vfsInitScript;
int found;
-#if defined(_WIN32) && !defined(STATIC_BUILD)
+#if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(STATIC_BUILD)
+# define LIBRARY_SIZE 64
HMODULE hModule;
WCHAR wName[MAX_PATH + LIBRARY_SIZE];
char dllName[(MAX_PATH + LIBRARY_SIZE) * 3];
@@ -3148,22 +3145,20 @@ TclZipfs_TclLibrary(void)
*/
#if !defined(STATIC_BUILD)
-#if defined(_WIN32)
+#if defined(_WIN32) || defined(__CYGWIN__)
hModule = TclWinGetTclInstance();
GetModuleFileNameW(hModule, wName, MAX_PATH);
+#ifdef __CYGWIN__
+ cygwin_conv_path(3, wName, dllName, sizeof(dllName));
+#else
WideCharToMultiByte(CP_UTF8, 0, wName, -1, dllName, sizeof(dllName), NULL, NULL);
+#endif
if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
#else
- if (ZipfsAppHookFindTclInit(
-#ifdef __CYGWIN__
- CFG_RUNTIME_BINDIR
-#else
- CFG_RUNTIME_LIBDIR
-#endif
- "/" CFG_RUNTIME_DLLFILE) == TCL_OK) {
+ if (ZipfsAppHookFindTclInit(CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
#endif /* _WIN32 */
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 3f1b728..7b32815 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -1532,7 +1532,6 @@ tclZipfs.o: $(GENERIC_DIR)/tclZipfs.c
$(CC) -c $(CC_SWITCHES) \
-DCFG_RUNTIME_DLLFILE="\"$(TCL_LIB_FILE)\"" \
-DCFG_RUNTIME_LIBDIR="\"$(libdir)\"" \
- -DCFG_RUNTIME_BINDIR="\"$(bindir)\"" \
-I$(ZLIB_DIR) -I$(ZLIB_DIR)/contrib/minizip \
$(GENERIC_DIR)/tclZipfs.c
diff --git a/unix/tclUnixFile.c b/unix/tclUnixFile.c
index 203a118..1ab5d14 100644
--- a/unix/tclUnixFile.c
+++ b/unix/tclUnixFile.c
@@ -44,8 +44,8 @@ TclpFindExecutable(
wchar_t buf[PATH_MAX];
char name[PATH_MAX * 3 + 1];
- GetModuleFileNameW(NULL, buf, PATH_MAX);
- cygwin_conv_path(3, buf, name, PATH_MAX);
+ GetModuleFileNameW(NULL, buf, sizeof(buf)/sizeof(wchar_t));
+ cygwin_conv_path(3, buf, name, sizeof(name));
length = strlen(name);
if ((length > 4) && !strcasecmp(name + length - 4, ".exe")) {
/* Strip '.exe' part. */
diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h
index e2f1104..ece0202 100644
--- a/unix/tclUnixPort.h
+++ b/unix/tclUnixPort.h
@@ -95,6 +95,8 @@ extern "C" {
# define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
# define HANDLE void *
# define HINSTANCE void *
+# define HMODULE void *
+# define MAX_PATH 260
# define SOCKET unsigned int
# define WSAEWOULDBLOCK 10035
typedef unsigned short WCHAR;
diff --git a/win/tclWinFile.c b/win/tclWinFile.c
index f89b522..1e0aca7 100644
--- a/win/tclWinFile.c
+++ b/win/tclWinFile.c
@@ -885,7 +885,7 @@ TclpFindExecutable(
Tcl_SetPanicProc(tclWinDebugPanic);
}
- GetModuleFileNameW(NULL, wName, MAX_PATH);
+ GetModuleFileNameW(NULL, wName, sizeof(wName)/sizeof(WCHAR));
WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
TclWinNoBackslash(name);
TclSetObjNameOfExecutable(Tcl_NewStringObj(name, -1), NULL);
diff --git a/win/tclWinInit.c b/win/tclWinInit.c
index a50d9eb..2830a85 100644
--- a/win/tclWinInit.c
+++ b/win/tclWinInit.c
@@ -334,8 +334,8 @@ InitializeDefaultLibraryDir(
char name[(MAX_PATH + LIBRARY_SIZE) * 3];
char *end, *p;
- GetModuleFileNameW(hModule, wName, MAX_PATH);
- WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, MAX_PATH * 3, NULL, NULL);
+ GetModuleFileNameW(hModule, wName, sizeof(wName)/sizeof(WCHAR));
+ WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
end = strrchr(name, '\\');
*end = '\0';
@@ -382,8 +382,8 @@ InitializeSourceLibraryDir(
char name[(MAX_PATH + LIBRARY_SIZE) * 3];
char *end, *p;
- GetModuleFileNameW(hModule, wName, MAX_PATH);
- WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, MAX_PATH * 3, NULL, NULL);
+ GetModuleFileNameW(hModule, wName, sizeof(wName)/sizeof(WCHAR));
+ WideCharToMultiByte(CP_UTF8, 0, wName, -1, name, sizeof(name), NULL, NULL);
end = strrchr(name, '\\');
*end = '\0';