From 4744cfd0bfab54584b7856280a0825dbada8ab2f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 21 Dec 2015 10:03:06 +0000 Subject: Undo more Android-specific changes, which don't form part of Zipfs, as further preparation for Zipfs TIP. Rename zipfs.h to tclZipfs.h, so it can be installed together with tcl.h --- generic/tclIOUtil.c | 2 +- generic/tclMain.c | 197 ---------------------------------------------------- generic/tclZipfs.h | 65 +++++++++++++++++ generic/zipfs.c | 6 +- generic/zipfs.h | 66 ------------------ unix/Makefile.in | 4 +- unix/configure | 18 ----- unix/configure.in | 8 --- unix/tclUnixInit.c | 8 --- win/Makefile.in | 1 + win/configure | 19 ----- win/configure.in | 8 --- win/makefile.vc | 1 + 13 files changed, 75 insertions(+), 328 deletions(-) create mode 100644 generic/tclZipfs.h delete mode 100644 generic/zipfs.h diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index 9bc868b..0ef6d3b 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -192,7 +192,7 @@ const Tcl_Filesystem tclNativeFilesystem = { }; #ifdef ZIPFS_IN_TCL -extern Tcl_Filesystem zipfsFilesystem; +MODULE_SCOPE Tcl_Filesystem zipfsFilesystem; #endif /* diff --git a/generic/tclMain.c b/generic/tclMain.c index 6acd15d..927de7e 100644 --- a/generic/tclMain.c +++ b/generic/tclMain.c @@ -34,15 +34,6 @@ #include "tclInt.h" -#ifdef ZIPFS_IN_TCL -#include "zipfs.h" -#endif - -#ifdef ANDROID -#undef ZIPFS_BOOTDIR -#define ZIPFS_BOOTDIR "/assets" -#endif - /* * The default prompt used when the user has not overridden it. */ @@ -60,7 +51,6 @@ # define TCHAR char # define TEXT(arg) arg # define _tcscmp strcmp -# define _tcsncmp strncmp #endif /* @@ -325,21 +315,9 @@ Tcl_MainEx( Tcl_MainLoopProc *mainLoopProc; Tcl_Channel chan; InteractiveState is; -#ifdef ZIPFS_IN_TCL - const char *zipFile = NULL; - Tcl_Obj *zipval = NULL; - int autoRun = 1; - int zipOk = TCL_ERROR; -#ifndef ANDROID - const char *exeName; -#endif -#endif TclpSetInitialEncodings(); TclpFindExecutable((const char *)argv[0]); -#if defined(ZIPFS_IN_TCL) && !defined(ANDROID) - exeName = Tcl_GetNameOfExecutable(); -#endif Tcl_InitMemory(interp); @@ -369,26 +347,6 @@ Tcl_MainEx( Tcl_DecrRefCount(value); argc -= 3; argv += 3; -#ifdef ZIPFS_IN_TCL - } else if (argc > 2) { - int length = strlen((char *) argv[1]); - if ((length >= 2) && - (0 == _tcsncmp(TEXT("-zip"), argv[1], length))) { - argc--; - argv++; - if ((argc > 1) && (argv[1][0] != (TCHAR) '-')) { - zipval = NewNativeObj(argv[1], -1); - zipFile = Tcl_GetString(zipval); - autoRun = 0; - argc--; - argv++; - } - } else if ('-' != argv[1][0]) { - Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL); - argc--; - argv++; - } -#endif } else if ((argc > 1) && ('-' != argv[1][0])) { Tcl_SetStartupScript(NewNativeObj(argv[1], -1), NULL); argc--; @@ -422,67 +380,6 @@ Tcl_MainEx( Tcl_SetVar2Ex(interp, "tcl_interactive", NULL, Tcl_NewIntObj(!path && is.tty), TCL_GLOBAL_ONLY); -#ifdef ZIPFS_IN_TCL - zipOk = Tclzipfs_Init(interp); - if (zipOk == TCL_OK) { - int relax = 0; - - if (zipFile == NULL) { - relax = 1; -#ifdef ANDROID - zipFile = getenv("PACKAGE_CODE_PATH"); - if (zipFile == NULL) { - zipFile = Tcl_GetNameOfExecutable(); - } -#else - zipFile = exeName; -#endif - } - if (zipFile != NULL) { -#ifdef ANDROID - zipOk = Tclzipfs_Mount(interp, zipFile, "", NULL); -#else - zipOk = Tclzipfs_Mount(interp, zipFile, exeName, NULL); -#endif - if (!relax && (zipOk != TCL_OK)) { - exitCode = 1; - goto done; - } - } else { - zipOk = TCL_ERROR; - } - Tcl_ResetResult(interp); - } - if (zipOk == TCL_OK) { -#ifdef ZIPFS_BOOTDIR - char *tcl_lib = ZIPFS_BOOTDIR "/tcl" TCL_VERSION; - char *tcl_pkg = ZIPFS_BOOTDIR; -#else - char *tcl_lib; - char *tcl_pkg = (char *) exeName; - Tcl_DString dsLib; - - Tcl_DStringInit(&dsLib); - Tcl_DStringAppend(&dsLib, exeName, -1); - Tcl_DStringAppend(&dsLib, "/tcl" TCL_VERSION, -1); - tcl_lib = Tcl_DStringValue(&dsLib); -#endif - Tcl_SetVar2(interp, "env", "TCL_LIBRARY", tcl_lib, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_libPath", tcl_lib, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_library", tcl_lib, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_pkgPath", tcl_pkg, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "auto_path", tcl_lib, - TCL_GLOBAL_ONLY | TCL_LIST_ELEMENT); -#ifndef ZIPFS_BOOTDIR - Tcl_DStringFree(&dsLib); -#endif - } - if (zipval != NULL) { - Tcl_DecrRefCount(zipval); - zipval = NULL; - } -#endif - /* * Invoke application-specific initialization. */ @@ -512,100 +409,6 @@ Tcl_MainEx( Tcl_CreateExitHandler(FreeMainInterp, interp); } -#ifdef ZIPFS_IN_TCL - /* - * Setup auto loading info to point to mounted ZIP file. - */ - - if (zipOk == TCL_OK) { -#ifdef ZIPFS_BOOTDIR - char *tcl_lib = ZIPFS_BOOTDIR "/tcl" TCL_VERSION; - char *tcl_pkg = ZIPFS_BOOTDIR; -#else - char *tcl_lib; - char *tcl_pkg = (char *) exeName; - Tcl_DString dsLib; - - Tcl_DStringInit(&dsLib); - Tcl_DStringAppend(&dsLib, exeName, -1); - Tcl_DStringAppend(&dsLib, "/tcl" TCL_VERSION, -1); - tcl_lib = Tcl_DStringValue(&dsLib); -#endif - Tcl_SetVar(interp, "tcl_libPath", tcl_lib, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_library", tcl_lib, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_pkgPath", tcl_pkg, TCL_GLOBAL_ONLY); -#ifndef ZIPFS_BOOTDIR - Tcl_DStringFree(&dsLib); -#endif - - /* - * We need to re-init encoding (after initializing Tcl), - * otherwise "encoding system" will return "identity" - */ - - TclpSetInitialEncodings(); - } - - /* - * Set embedded application startup file, if any. - */ - - if ((zipOk == TCL_OK) && autoRun) { - char *filename; - Tcl_Channel chan; -#ifdef ZIPFS_BOOTDIR - filename = ZIPFS_BOOTDIR "/app/main.tcl"; -#else - Tcl_DString dsFile; - - Tcl_DStringInit(&dsFile); - Tcl_DStringAppend(&dsFile, exeName, -1); - Tcl_DStringAppend(&dsFile, "/app/main.tcl", -1); - filename = Tcl_DStringValue(&dsFile); -#endif - chan = Tcl_OpenFileChannel(NULL, filename, "r", 0); - if (chan != (Tcl_Channel) NULL) { - Tcl_Obj *arg; - - Tcl_Close(NULL, chan); - - /* - * Push back script file to argv, if any. - */ - if ((arg = Tcl_GetStartupScript(NULL)) != NULL) { - Tcl_Obj *v, *no; - - no = Tcl_NewStringObj("argv", 4); - v = Tcl_ObjGetVar2(interp, no, NULL, TCL_GLOBAL_ONLY); - if (v != NULL) { - Tcl_Obj **objv, *nv; - int objc, i; - - objc = 0; - Tcl_ListObjGetElements(NULL, v, &objc, &objv); - nv = Tcl_NewListObj(1, &arg); - for (i = 0; i < objc; i++) { - Tcl_ListObjAppendElement(NULL, nv, objv[i]); - } - Tcl_IncrRefCount(nv); - if (Tcl_ObjSetVar2(interp, no, NULL, nv, TCL_GLOBAL_ONLY) - != NULL) { - Tcl_GlobalEval(interp, "incr argc"); - } - Tcl_DecrRefCount(nv); - } - Tcl_DecrRefCount(no); - } - Tcl_SetStartupScript(Tcl_NewStringObj(filename, -1), NULL); - Tcl_SetVar(interp, "argv0", filename, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); - } -#ifndef ANDROID - Tcl_DStringFree(&dsFile); -#endif - } -#endif - /* * Invoke the script specified on the command line, if any. Must fetch it * again, as the appInitProc might have reset it. diff --git a/generic/tclZipfs.h b/generic/tclZipfs.h new file mode 100644 index 0000000..bf3a3cb --- /dev/null +++ b/generic/tclZipfs.h @@ -0,0 +1,65 @@ +/* + * tclZipfs.h -- + * + * This header file describes the interface of the ZIPFS filesystem + * + * Copyright (c) 2013-2015 Christian Werner + * + * See the file "license.terms" for information on usage and redistribution of + * this file, and for a DISCLAIMER OF ALL WARRANTIES. + */ + +#ifndef _ZIPFS_H +#define _ZIPFS_H + +#include "tcl.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef ZIPFSAPI +# define ZIPFSAPI extern +#endif + +#ifdef ZIPFS_IN_TK +#define Zipfs_Mount Tkzipfs_Mount +#define Zipfs_Unmount Tkzipfs_Unmount +#define Zipfs_Init Tkzipfs_Init +#define Zipfs_SafeInit Tkzipfs_SafeInit +#ifdef BUILD_tk +# undef ZIPFSAPI +# define ZIPFSAPI DLLEXPORT +#endif +#endif + +#ifdef ZIPFS_IN_TCL +#define Zipfs_Mount Tclzipfs_Mount +#define Zipfs_Unmount Tclzipfs_Unmount +#define Zipfs_Init Tclzipfs_Init +#define Zipfs_SafeInit Tclzipfs_SafeInit +#ifdef BUILD_tcl +# undef ZIPFSAPI +# define ZIPFSAPI DLLEXPORT +#endif +#endif + +ZIPFSAPI int Zipfs_Mount(Tcl_Interp *interp, CONST char *zipname, + CONST char *mntpt, CONST char *passwd); +ZIPFSAPI int Zipfs_Unmount(Tcl_Interp *interp, CONST char *zipname); +ZIPFSAPI int Zipfs_Init(Tcl_Interp *interp); +ZIPFSAPI int Zipfs_SafeInit(Tcl_Interp *interp); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZIPFS_H */ + +/* + * Local Variables: + * mode: c + * c-basic-offset: 4 + * fill-column: 78 + * End: + */ diff --git a/generic/zipfs.c b/generic/zipfs.c index 0683c32..6d49f4f 100644 --- a/generic/zipfs.c +++ b/generic/zipfs.c @@ -24,7 +24,7 @@ #endif #include "tclInt.h" #include "tclFileSystem.h" -#include "zipfs.h" +#include "tclZipfs.h" #ifdef HAVE_ZLIB @@ -3821,7 +3821,9 @@ Zip_FSLoadFile(Tcl_Interp *interp, Tcl_Obj *path, Tcl_LoadHandle *loadHandle, * Define the ZIP filesystem dispatch table. */ -Tcl_Filesystem zipfsFilesystem = { +MODULE_SCOPE const Tcl_Filesystem zipfsFilesystem; + +const Tcl_Filesystem zipfsFilesystem = { "zipfs", sizeof (Tcl_Filesystem), TCL_FILESYSTEM_VERSION_2, diff --git a/generic/zipfs.h b/generic/zipfs.h deleted file mode 100644 index 15ca37c..0000000 --- a/generic/zipfs.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * zipfs.h -- - * - * This header file describes the interface of the ZIPFS filesystem - * used in AndroWish. - * - * Copyright (c) 2013-2015 Christian Werner - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#ifndef _ZIPFS_H -#define _ZIPFS_H - -#include "tcl.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef ZIPFSAPI -# define ZIPFSAPI extern -#endif - -#ifdef ZIPFS_IN_TK -#define Zipfs_Mount Tkzipfs_Mount -#define Zipfs_Unmount Tkzipfs_Unmount -#define Zipfs_Init Tkzipfs_Init -#define Zipfs_SafeInit Tkzipfs_SafeInit -#ifdef BUILD_tk -# undef ZIPFSAPI -# define ZIPFSAPI DLLEXPORT -#endif -#endif - -#ifdef ZIPFS_IN_TCL -#define Zipfs_Mount Tclzipfs_Mount -#define Zipfs_Unmount Tclzipfs_Unmount -#define Zipfs_Init Tclzipfs_Init -#define Zipfs_SafeInit Tclzipfs_SafeInit -#ifdef BUILD_tcl -# undef ZIPFSAPI -# define ZIPFSAPI DLLEXPORT -#endif -#endif - -ZIPFSAPI int Zipfs_Mount(Tcl_Interp *interp, CONST char *zipname, - CONST char *mntpt, CONST char *passwd); -ZIPFSAPI int Zipfs_Unmount(Tcl_Interp *interp, CONST char *zipname); -ZIPFSAPI int Zipfs_Init(Tcl_Interp *interp); -ZIPFSAPI int Zipfs_SafeInit(Tcl_Interp *interp); - -#ifdef __cplusplus -} -#endif - -#endif /* _ZIPFS_H */ - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ diff --git a/unix/Makefile.in b/unix/Makefile.in index ebbd61c..c09fb35 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -373,6 +373,7 @@ GENERIC_HDRS = \ $(GENERIC_DIR)/tclInt.h \ $(GENERIC_DIR)/tclIntDecls.h \ $(GENERIC_DIR)/tclIntPlatDecls.h \ + $(GENERIC_DIR)/tclZipfs.h \ $(GENERIC_DIR)/tclTomMath.h \ $(GENERIC_DIR)/tclTomMathDecls.h \ $(GENERIC_DIR)/tclOO.h \ @@ -383,7 +384,7 @@ GENERIC_HDRS = \ $(GENERIC_DIR)/tclPlatDecls.h \ $(GENERIC_DIR)/tclPort.h \ $(GENERIC_DIR)/tclRegexp.h \ - $(GENERIC_DIR)/zipfs.h + $(GENERIC_DIR)/tclZipfs.h GENERIC_SRCS = \ $(GENERIC_DIR)/regcomp.c \ @@ -954,6 +955,7 @@ install-headers: @for i in $(GENERIC_DIR)/tcl.h $(GENERIC_DIR)/tclDecls.h \ $(GENERIC_DIR)/tclOO.h $(GENERIC_DIR)/tclOODecls.h \ $(GENERIC_DIR)/tclPlatDecls.h \ + $(GENERIC_DIR)/tclZipfs.h \ $(GENERIC_DIR)/tclTomMath.h \ $(GENERIC_DIR)/tclTomMathDecls.h ; \ do \ diff --git a/unix/configure b/unix/configure index 3e72a0d..c19a77a 100755 --- a/unix/configure +++ b/unix/configure @@ -869,7 +869,6 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-encoding encoding for configuration values (default: iso8859-1) - --with-zipfs include ZIP filesystem --with-tzdata install timezone data (default: autodetect) Some influential environment variables: @@ -6212,23 +6211,6 @@ cat >>confdefs.h <<\_ACEOF _ACEOF -# Check whether --with-zipfs or --without-zipfs was given. -if test "${with_zipfs+set}" = set; then - withval="$with_zipfs" - tcl_ok=$withval -else - tcl_ok=no -fi; -echo "$as_me:$LINENO: result: $tcl_ok" >&5 -echo "${ECHO_T}$tcl_ok" >&6 -if test $tcl_ok = yes; then - -cat >>confdefs.h <<\_ACEOF -#define ZIPFS_IN_TCL 1 -_ACEOF - -fi - #-------------------------------------------------------------------- # The statements below define a collection of compile flags. This # macro depends on the value of SHARED_BUILD, and should be called diff --git a/unix/configure.in b/unix/configure.in index 7eeff3b..c7b0edc 100644 --- a/unix/configure.in +++ b/unix/configure.in @@ -171,14 +171,6 @@ AS_IF([test $zlib_ok = no], [ AC_SUBST(ZLIB_INCLUDE,[-I\${ZLIB_DIR}]) ]) AC_DEFINE(HAVE_ZLIB, 1, [Is there an installed zlib?]) -AC_ARG_WITH(zipfs, - AC_HELP_STRING([--with-zipfs], - [include ZIP filesystem]), - [tcl_ok=$withval], [tcl_ok=no]) -AC_MSG_RESULT([$tcl_ok]) -if test $tcl_ok = yes; then - AC_DEFINE(ZIPFS_IN_TCL, 1, [Include ZIP filesystem?]) -fi #-------------------------------------------------------------------- # The statements below define a collection of compile flags. This diff --git a/unix/tclUnixInit.c b/unix/tclUnixInit.c index e8ccc76..5e4ef0a 100644 --- a/unix/tclUnixInit.c +++ b/unix/tclUnixInit.c @@ -9,9 +9,6 @@ */ #include "tclInt.h" -#ifdef ZIPFS_IN_TCL -#include "zipfs.h" -#endif #include #include #ifdef HAVE_LANGINFO @@ -544,11 +541,6 @@ TclpInitLibraryPath( */ str = defaultLibraryDir; -#ifdef ZIPFS_IN_TCL - if (Tclzipfs_Mount(NULL, NULL, NULL, NULL) == TCL_OK) { - str = ""; - } -#endif } if (str[0] != '\0') { objPtr = Tcl_NewStringObj(str, -1); diff --git a/win/Makefile.in b/win/Makefile.in index 00f5c99..f6d006b 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -636,6 +636,7 @@ install-libraries: libraries install-tzdata install-msgs @echo "Installing header files"; @for i in "$(GENERIC_DIR)/tcl.h" "$(GENERIC_DIR)/tclDecls.h" \ "$(GENERIC_DIR)/tclOO.h" "$(GENERIC_DIR)/tclOODecls.h" \ + "$(GENERIC_DIR)/tclZipfs.h" \ "$(GENERIC_DIR)/tclPlatDecls.h" \ "$(GENERIC_DIR)/tclTomMath.h" \ "$(GENERIC_DIR)/tclTomMathDecls.h"; \ diff --git a/win/configure b/win/configure index 27f2c10..3ebc697 100755 --- a/win/configure +++ b/win/configure @@ -853,7 +853,6 @@ Optional Packages: --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-encoding encoding for configuration values --with-celib=DIR use Windows/CE support library from DIR - --with-zipfs include ZIP filesystem Some influential environment variables: CC C compiler command @@ -4409,24 +4408,6 @@ cat >>confdefs.h <<\_ACEOF _ACEOF -# Check whether --with-zipfs or --without-zipfs was given. -if test "${with_zipfs+set}" = set; then - withval="$with_zipfs" - tcl_ok=$withval -else - tcl_ok=no -fi; -echo "$as_me:$LINENO: result: $tcl_ok" >&5 -echo "${ECHO_T}$tcl_ok" >&6 -if test $tcl_ok = yes; then - -cat >>confdefs.h <<\_ACEOF -#define ZIPFS_IN_TCL 1 -_ACEOF - -fi - - echo "$as_me:$LINENO: checking for intptr_t" >&5 echo $ECHO_N "checking for intptr_t... $ECHO_C" >&6 if test "${ac_cv_type_intptr_t+set}" = set; then diff --git a/win/configure.in b/win/configure.in index c8ab2e3..9e9df90 100644 --- a/win/configure.in +++ b/win/configure.in @@ -141,14 +141,6 @@ AS_IF([test "$tcl_ok" = "yes"], [ AC_SUBST(ZLIB_OBJS,[\${ZLIB_OBJS}]) ]) AC_DEFINE(HAVE_ZLIB, 1, [Is there an installed zlib?]) -AC_ARG_WITH(zipfs, - AC_HELP_STRING([--with-zipfs], - [include ZIP filesystem]), - [tcl_ok=$withval], [tcl_ok=no]) -AC_MSG_RESULT([$tcl_ok]) -if test $tcl_ok = yes; then - AC_DEFINE(ZIPFS_IN_TCL, 1, [Include ZIP filesystem?]) -fi AC_CHECK_TYPE([intptr_t], [ AC_DEFINE([HAVE_INTPTR_T], 1, [Do we have the intptr_t type?])], [ diff --git a/win/makefile.vc b/win/makefile.vc index ecfcecf..82dd655 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -1115,6 +1115,7 @@ install-libraries: tclConfig install-msgs install-tzdata @$(CPY) "$(GENERICDIR)\tclDecls.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclOO.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclOODecls.h" "$(INCLUDE_INSTALL_DIR)\" + @$(CPY) "$(GENERICDIR)\tclZipfs.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclPlatDecls.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclTomMath.h" "$(INCLUDE_INSTALL_DIR)\" @$(CPY) "$(GENERICDIR)\tclTomMathDecls.h" "$(INCLUDE_INSTALL_DIR)\" -- cgit v0.12