summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2023-11-01 20:21:03 (GMT)
committerdgp <dgp@users.sourceforge.net>2023-11-01 20:21:03 (GMT)
commit69fb959ca642175270a38faf7bfab40da094a9b7 (patch)
tree1e2d700d1cabcbb06b32d19fb4f43737f532aa51
parent6963024f13c68b475b0768c3ba23d9ee53ba8f14 (diff)
downloadtcl-69fb959ca642175270a38faf7bfab40da094a9b7.zip
tcl-69fb959ca642175270a38faf7bfab40da094a9b7.tar.gz
tcl-69fb959ca642175270a38faf7bfab40da094a9b7.tar.bz2
When there is a zipfs archive in use to house the script library and
TclZipfs_TclLibrary() is called to confirm the presence of an init.tcl file in it, include in that routine setting up the encoding subdirectory as the default encoding search path. We know early we are using an archive. Don't let the library go off on a wild search through the native filesystem looking for the encoding data files.
-rw-r--r--generic/tclZipfs.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 9372079..842d51a 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -327,6 +327,7 @@ static int InitWritableChannel(Tcl_Interp *interp,
static int ListMountPoints(Tcl_Interp *interp);
static int ContainsMountPoint(const char *path, int pathLen);
static void CleanupMount(ZipFile *zf);
+static Tcl_Obj * ScriptLibrarySetup(const char *dirName);
static void SerializeCentralDirectoryEntry(
const unsigned char *start,
const unsigned char *end, unsigned char *buf,
@@ -4222,6 +4223,26 @@ ZipFSListObjCmd(
*-------------------------------------------------------------------------
*/
+/* Utility routine to centralize housekeeping */
+static Tcl_Obj *
+ScriptLibrarySetup(
+ const char *dirName)
+{
+ Tcl_Obj *libDirObj = Tcl_NewStringObj(dirName, -1);
+ Tcl_Obj *subDirObj, *searchPathObj;
+
+ TclNewLiteralStringObj(subDirObj, "encoding");
+ Tcl_IncrRefCount(subDirObj);
+ TclNewObj(searchPathObj);
+ Tcl_ListObjAppendElement(NULL, searchPathObj,
+ Tcl_FSJoinToPath(libDirObj, 1, &subDirObj));
+ Tcl_DecrRefCount(subDirObj);
+ Tcl_IncrRefCount(searchPathObj);
+ Tcl_SetEncodingSearchPath(searchPathObj);
+ Tcl_DecrRefCount(searchPathObj);
+ return libDirObj;
+}
+
Tcl_Obj *
TclZipfs_TclLibrary(void)
{
@@ -4240,7 +4261,7 @@ TclZipfs_TclLibrary(void)
*/
if (zipfs_literal_tcl_library) {
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
/*
@@ -4254,7 +4275,7 @@ TclZipfs_TclLibrary(void)
Tcl_DecrRefCount(vfsInitScript);
if (found == TCL_OK) {
zipfs_literal_tcl_library = ZIPFS_APP_MOUNT "/tcl_library";
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
/*
@@ -4273,17 +4294,17 @@ TclZipfs_TclLibrary(void)
#endif
if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) {
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
#elif !defined(NO_DLFCN_H)
Dl_info dlinfo;
if (dladdr((const void *)TclZipfs_TclLibrary, &dlinfo) && (dlinfo.dli_fname != NULL)
&& (ZipfsAppHookFindTclInit(dlinfo.dli_fname) == TCL_OK)) {
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
#else
if (ZipfsAppHookFindTclInit(CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE) == TCL_OK) {
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
#endif /* _WIN32 */
#endif /* !defined(STATIC_BUILD) */
@@ -4294,7 +4315,7 @@ TclZipfs_TclLibrary(void)
*/
if (zipfs_literal_tcl_library) {
- return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ return ScriptLibrarySetup(zipfs_literal_tcl_library);
}
return NULL;
}