From bd8b8ff3b710e8ae5f4750eadc84c9d96c3ea4c7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 Feb 2021 10:14:01 +0000 Subject: Final implementation tweaks, fix comments, allow Tcl to load from /lib (or /bin on win32/cygwin) even when this is not in your PATH. --- doc/zipfs.3 | 4 ++-- generic/tclStubCall.c | 22 ++++++++++++++++++---- generic/tclStubLib.c | 2 +- generic/tclStubLibTbl.c | 2 +- unix/Makefile.in | 7 +++++-- unix/configure.ac | 4 ---- win/Makefile.in | 5 ++++- win/makefile.vc | 5 ++++- 8 files changed, 35 insertions(+), 16 deletions(-) diff --git a/doc/zipfs.3 b/doc/zipfs.3 index f1efc65..2db6d67 100644 --- a/doc/zipfs.3 +++ b/doc/zipfs.3 @@ -87,8 +87,8 @@ it uses WCHAR instead of char. As a result, it requires your application to be compiled with the UNICODE preprocessor symbol defined (e.g., via the \fB-DUNICODE\fR compiler flag). .PP -The result of \fBTclZipfs_AppHook\fR is the Tcl version string(e.g., \fB"9.0"\fR -when the function is successful). The function \fImay\fR modify the variables +The result of \fBTclZipfs_AppHook\fR is the full Tcl version string(e.g., +\fB"9.0.0"\fR). The function \fImay\fR modify the variables pointed to by \fIargcPtr\fR and \fIargvPtr\fR to remove arguments; the current implementation does not do so, but callers \fIshould not\fR assume that this will be true in the future. diff --git a/generic/tclStubCall.c b/generic/tclStubCall.c index 8fe7892..96e3837 100644 --- a/generic/tclStubCall.c +++ b/generic/tclStubCall.c @@ -59,7 +59,7 @@ static const char CANNOTFIND[] = "Cannot find %s: %s\n"; MODULE_SCOPE void * TclStubCall(void *arg) { - static void *stubFn[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL}; + static void *stubFn[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; unsigned index = PTR2UINT(arg); if (index >= sizeof(PROCNAME)/sizeof(PROCNAME[0])) { @@ -76,12 +76,26 @@ TclStubCall(void *arg) } if (!stubFn[index]) { if (!tclStubsHandle) { - tclStubsHandle = dlopen(TCL_DLL_FILE, RTLD_NOW|RTLD_LOCAL); + tclStubsHandle = dlopen(CFG_RUNTIME_DLLFILE, RTLD_NOW|RTLD_LOCAL); + if (!tclStubsHandle) { + tclStubsHandle = dlopen( +#if defined(_WIN32) || defined(__CYGWIN__) + CFG_RUNTIME_BINDIR +#else + CFG_RUNTIME_LIBDIR +#endif +#if defined(_WIN32) + "\\" +#else + "/" +#endif + CFG_RUNTIME_DLLFILE, RTLD_NOW|RTLD_LOCAL); + } if (!tclStubsHandle) { if ((index == 0) && (arg != NULL)) { - ((Tcl_PanicProc *)arg)(CANNOTFIND, TCL_DLL_FILE, dlerror()); + ((Tcl_PanicProc *)arg)(CANNOTFIND, CFG_RUNTIME_DLLFILE, dlerror()); } else { - fprintf(stderr, CANNOTFIND, TCL_DLL_FILE, dlerror()); + fprintf(stderr, CANNOTFIND, CFG_RUNTIME_DLLFILE, dlerror()); abort(); } } diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c index 32ca1f1..697d92f 100644 --- a/generic/tclStubLib.c +++ b/generic/tclStubLib.c @@ -109,7 +109,7 @@ Tcl_InitStubs( stubsPtr = (TclStubs *)pkgData; } if (tclStubsHandle == NULL) { - tclStubsHandle = (void *) -1; + tclStubsHandle = INT2PTR(-1); } tclStubsPtr = stubsPtr; diff --git a/generic/tclStubLibTbl.c b/generic/tclStubLibTbl.c index 32b3869..ad34494 100644 --- a/generic/tclStubLibTbl.c +++ b/generic/tclStubLibTbl.c @@ -40,7 +40,7 @@ TclInitStubTable( if (tclStubsHandle == NULL) { /* This can only happen with -DBUILD_STATIC, so simulate * that the loading of Tcl succeeded, although we didn't - * actually loaded it dynamically */ + * actually load it dynamically */ tclStubsHandle = (void *)1; } tclStubsPtr = ((const TclStubs **) version)[-1]; diff --git a/unix/Makefile.in b/unix/Makefile.in index 4e7b06c..936f2f2 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -201,7 +201,6 @@ BUILD_DLTEST = @BUILD_DLTEST@ TCL_LIB_FILE = @TCL_LIB_FILE@ #TCL_LIB_FILE = libtcl.a -TCL_PREV_LIB_FILE = @TCL_PREV_LIB_FILE@ # Generic lib name used in rules that apply to tcl and tk LIB_FILE = ${TCL_LIB_FILE} @@ -1914,7 +1913,11 @@ tclStubLib.o: $(GENERIC_DIR)/tclStubLib.c $(CC) -c $(STUB_CC_SWITCHES) -DSTATIC_BUILD @CFLAGS_NOLTO@ $(GENERIC_DIR)/tclStubLib.c tclStubCall.o: $(GENERIC_DIR)/tclStubCall.c - $(CC) -c $(STUB_CC_SWITCHES) -DSTATIC_BUILD -DTCL_DLL_FILE="\"$(TCL_LIB_FILE)\"" $(GENERIC_DIR)/tclStubCall.c + $(CC) -c $(STUB_CC_SWITCHES) -DSTATIC_BUILD \ + -DCFG_RUNTIME_DLLFILE="\"$(TCL_LIB_FILE)\"" \ + -DCFG_RUNTIME_LIBDIR="\"$(libdir)\"" \ + -DCFG_RUNTIME_BINDIR="\"$(bindir)\"" \ + $(GENERIC_DIR)/tclStubCall.c tclStubLibTbl.o: $(GENERIC_DIR)/tclStubLibTbl.c $(CC) -c $(STUB_CC_SWITCHES) -DSTATIC_BUILD $(GENERIC_DIR)/tclStubLibTbl.c diff --git a/unix/configure.ac b/unix/configure.ac index 08aa2b3..685a335 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -864,9 +864,6 @@ else TCL_BUILD_LIB_SPEC="-L`pwd | sed -e 's/ /\\\\ /g'` ${TCL_LIB_FLAG}" TCL_LIB_SPEC="-L${libdir} ${TCL_LIB_FLAG}" fi -VERSION='8.5' -eval "TCL_PREV_LIB_FILE=libtcl${TCL_SHARED_LIB_SUFFIX}" -eval "TCL_PREV_LIB_FILE=${TCL_PREV_LIB_FILE}" VERSION='${VERSION}' eval "CFG_TCL_SHARED_LIB_SUFFIX=${TCL_SHARED_LIB_SUFFIX}" eval "CFG_TCL_UNSHARED_LIB_SUFFIX=${TCL_UNSHARED_LIB_SUFFIX}" @@ -974,7 +971,6 @@ AC_SUBST(PKG_CFG_ARGS) AC_SUBST(TCL_ZIP_FILE) AC_SUBST(TCL_LIB_FILE) -AC_SUBST(TCL_PREV_LIB_FILE) AC_SUBST(TCL_LIB_FLAG) AC_SUBST(TCL_LIB_SPEC) AC_SUBST(TCL_STUB_LIB_FILE) diff --git a/win/Makefile.in b/win/Makefile.in index 57cb7ef..1ce1c9d 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -682,7 +682,10 @@ tclStubLib.${OBJEXT}: tclStubLib.c $(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD @CFLAGS_NOLTO@ @DEPARG@ $(CC_OBJNAME) tclStubCall.${OBJEXT}: tclStubCall.c - $(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD -DTCL_DLL_FILE="\"$(TCL_DLL_FILE)\"" @DEPARG@ $(CC_OBJNAME) + $(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD \ + -DCFG_RUNTIME_DLLFILE="\"$(TCL_DLL_FILE)\"" \ + -DCFG_RUNTIME_BINDIR="\"$(bindir_native)\"" \ + @DEPARG@ $(CC_OBJNAME) tclStubLibTbl.${OBJEXT}: tclStubLibTbl.c $(CC) -c $(CC_SWITCHES) -DSTATIC_BUILD @DEPARG@ $(CC_OBJNAME) diff --git a/win/makefile.vc b/win/makefile.vc index 67c7c36..03a4419 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -864,7 +864,10 @@ $(TMP_DIR)\tclStubLib.obj: $(GENERICDIR)\tclStubLib.c $(cc32) $(stubscflags) -Fo$@ $? $(TMP_DIR)\tclStubCall.obj: $(GENERICDIR)\tclStubCall.c - $(cc32) $(stubscflags) -DTCL_DLL_FILE="\"tcl$(TCL_VERSION)$(SUFX:t=).dll\"" $(TCL_INCLUDES) -Fo$@ $? + $(cc32) $(stubscflags) \ + /DCFG_RUNTIME_DLLFILE="\"$(TCLLIBNAME)\"" \ + /DCFG_RUNTIME_BINDIR="\"$(BIN_INSTALL_DIR:\=\\)\"" \ + $(TCL_INCLUDES) -Fo$@ $? $(TMP_DIR)\tclStubLibTbl.obj: $(GENERICDIR)\tclStubLibTbl.c $(cc32) $(stubscflags) $(TCL_INCLUDES) -Fo$@ $? -- cgit v0.12