GraphicsMagick: TclMagick: Eliminate the libttkcommon "shim" lib...
GraphicsMagick Commits <[email protected]> Wed, 02 Oct 2024 09:07:39 -0500
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.25179.1727878069.7812.graphicsmagick-commit@lists.sourceforge.net> |
changeset 81eb6070fb80 in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=81eb6070fb80 summary: TclMagick: Eliminate the libttkcommon "shim" library which allowed TkMagick to work and use a different approach. TclMagick is not dependent on libtk. diffstat: ChangeLog | 7 ++ TclMagick/ChangeLog | 65 ++++++++++++++++++++- TclMagick/Makefile.am | 18 ++-- TclMagick/Makefile.in | 56 ++++------------- TclMagick/generic/TclMagick.c | 95 +++++++++++++++++++++++++----- TclMagick/generic/TkMagick.c | 21 ++++++- TclMagick/generic/libttkcommon.c | 101 --------------------------------- TclMagick/generic/libttkcommon.h | 41 +++++++++++- VisualMagick/installer/inc/version.isx | 4 +- magick/version.h | 4 +- www/ChangeLog.html | 9 ++ 11 files changed, 241 insertions(+), 180 deletions(-) diffs (truncated from 738 to 500 lines): diff -r b99b057947ca -r 81eb6070fb80 ChangeLog --- a/ChangeLog Sun Sep 29 09:36:36 2024 -0500 +++ b/ChangeLog Wed Oct 02 09:07:23 2024 -0500 @@ -1,3 +1,10 @@ +2024-10-02 Bob Friesenhahn <[email protected]> + + * TclMagick/Makefile.am: Eliminate the libttkcommon "shim" library + which allowed TkMagick to work and use a different approach. + TclMagick is not dependent on libtk. Only TkMagick is dependent + on libtk. + 2024-09-29 Bob Friesenhahn <[email protected]> * www/links.rst: Update oss-fuzz bug tracker URL. diff -r b99b057947ca -r 81eb6070fb80 TclMagick/ChangeLog --- a/TclMagick/ChangeLog Sun Sep 29 09:36:36 2024 -0500 +++ b/TclMagick/ChangeLog Wed Oct 02 09:07:23 2024 -0500 @@ -1,3 +1,66 @@ +2024-10-02 Bob Friesenhahn <[email protected]> + + * Makefile.am: Eliminate the libttkcommon "shim" library which + allowed TkMagick to work and use a different approach. TclMagick + is not dependent on libtk. Only TkMagick is dependent on libtk. + +2024-09-26 Bob Friesenhahn <[email protected]> + + * unix/m4: Update to libtool 2.5.3. + +2024-09-24 Bob Friesenhahn <[email protected]> + + * Makefile.am: 'make test' does something. Not sure yet + what it should be. + + * tests/test-wand.tcl: Fix memory leak of $img and $seq. + + * tests/test-draw.tcl: Fix memory leak of $img. + + * generic/TclMagickAppInit.c: Add a TclMagick test program. + + * generic/TkMagick.c: Fix memory leak of 'fonts' and + 'formats' lists members. + +2024-09-20 Bob Friesenhahn <[email protected]> + + * Makefile.am: Now uses non-recursive build and produces + xz tarball. The make 'distcheck' target is not working properly + yet. + (AM_DISTCHECK_CONFIGURE_FLAGS): Change the argument to + --exec-prefix so that 'make distcheck' now passes. + +2024-09-19 Bob Friesenhahn <[email protected]> + + * generic/config.h.in, generic/libttkcommon.h: + Support a configuration header. + + * configure.ac: Modernize Autoconf files. + + * Makefile.am: Modernize Automake files. + +2024-09-15 Bob Friesenhahn <[email protected]> + + * generic/TclMagick.c: Fix several typos which will + produce wrong results, as well as quieting fallthrough warnings. + +2024-09-02 Bob Friesenhahn <[email protected]> + + * : White-space clean-up and consistent indentation. + +2024-09-01 Bob Friesenhahn <[email protected]> + + * unix/m4/tcl.m4: Update tcl.m4 to TEA_VERSION 3.10. + The TEA_INSTALLER Autoconf macro oddly does not use the settings + set by AC_CONFIG_AUX_DIR to find install-sh. Instead it + hard-codes $(srcdir)/tclconfig/install-sh. Change that hard-coded + path to $(top_srcdir)/unix/config/install-sh. + + * generic/pkgIndex.tcl: Remove generated file. + + * generic: Regenerate Autotool's generated files with + autoconf 2.71 and automake 1.16.5. + 2019-11-10 Bob Friesenhahn <[email protected]> * pkgIndex.tcl: Incorporate recommendations from third problem @@ -45,7 +108,7 @@ * generic/Makefile.am: Applied patch by Massimo Manghi (plus some fixes by me) to add a 'libttkcommon' shared library to contain - codde common to the TclMagick/TkMagick loadable modules, and + code common to the TclMagick/TkMagick loadable modules, and particularly to allow TkMagick to access TclMagick functions without depending on dlopen() with RTLD_GLOBAL behavior. diff -r b99b057947ca -r 81eb6070fb80 TclMagick/Makefile.am --- a/TclMagick/Makefile.am Sun Sep 29 09:36:36 2024 -0500 +++ b/TclMagick/Makefile.am Wed Oct 02 09:07:23 2024 -0500 @@ -18,21 +18,16 @@ # Put this in its own package directory. generic_lib_magickdir = @libdir@/TclMagick@VERSION@ -generic_lib_magick_LTLIBRARIES = generic/libttkcommon.la generic/TclMagick.la generic/TkMagick.la - -generic_libttkcommon_la_SOURCES = generic/libttkcommon.c generic/libttkcommon.h -generic_libttkcommon_la_LDFLAGS = @GM_LDFLAGS@ -no-undefined -generic_libttkcommon_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ @GM_LIBS@ -generic_libttkcommon_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ +generic_lib_magick_LTLIBRARIES = generic/TclMagick.la generic/TkMagick.la generic_TclMagick_la_SOURCES = generic/TclMagick.c generic/TclMagick.h generic/libttkcommon.h generic_TclMagick_la_LDFLAGS = @GM_LDFLAGS@ -L$(generic_lib_magickdir) -no-undefined -module -generic_TclMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIBS@ @TCL_LIBS@ @GM_LIBS@ generic/libttkcommon.la +generic_TclMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIBS@ @TCL_LIBS@ @GM_LIBS@ generic_TclMagick_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ generic_TkMagick_la_SOURCES = generic/TkMagick.c generic/TclMagick.h generic/libttkcommon.h generic_TkMagick_la_LDFLAGS = @GM_LDFLAGS@ -L$(generic_lib_magickdir) -no-undefined -module -generic_TkMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TK_STUB_LIB_SPEC@ @TCL_LIBS@ @TK_LIBS@ @GM_LIBS@ generic/libttkcommon.la +generic_TkMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TK_STUB_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ @TK_LIB_SPEC@ @TK_LIBS@ @GM_LIBS@ generic_TkMagick_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ @TK_INCLUDES@ @TK_XINCLUDES@ # A TclMagick executable (not installed) @@ -82,7 +77,12 @@ cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-pixel.tcl` cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-draw.tcl` cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-bmp-compare.tcl` -# cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-wand.tcl + +check: + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-wand.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-pixel.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-draw.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-bmp-compare.tcl #test: # cd generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-wand.tcl` $(TESTFLAGS) \ diff -r b99b057947ca -r 81eb6070fb80 TclMagick/Makefile.in --- a/TclMagick/Makefile.in Sun Sep 29 09:36:36 2024 -0500 +++ b/TclMagick/Makefile.in Wed Oct 02 09:07:23 2024 -0500 @@ -144,7 +144,7 @@ } am__installdirs = "$(DESTDIR)$(generic_lib_magickdir)" LTLIBRARIES = $(generic_lib_magick_LTLIBRARIES) -generic_TclMagick_la_DEPENDENCIES = generic/libttkcommon.la +generic_TclMagick_la_DEPENDENCIES = am__dirstamp = $(am__leading_dot)dirstamp am_generic_TclMagick_la_OBJECTS = generic/TclMagick_la-TclMagick.lo generic_TclMagick_la_OBJECTS = $(am_generic_TclMagick_la_OBJECTS) @@ -156,22 +156,13 @@ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(generic_TclMagick_la_LDFLAGS) \ $(LDFLAGS) -o $@ -generic_TkMagick_la_DEPENDENCIES = generic/libttkcommon.la +generic_TkMagick_la_DEPENDENCIES = am_generic_TkMagick_la_OBJECTS = generic/TkMagick_la-TkMagick.lo generic_TkMagick_la_OBJECTS = $(am_generic_TkMagick_la_OBJECTS) generic_TkMagick_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(generic_TkMagick_la_LDFLAGS) \ $(LDFLAGS) -o $@ -generic_libttkcommon_la_DEPENDENCIES = -am_generic_libttkcommon_la_OBJECTS = \ - generic/libttkcommon_la-libttkcommon.lo -generic_libttkcommon_la_OBJECTS = \ - $(am_generic_libttkcommon_la_OBJECTS) -generic_libttkcommon_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(generic_libttkcommon_la_LDFLAGS) \ - $(LDFLAGS) -o $@ am_generic_TclMagick_OBJECTS = \ generic/TclMagick-TclMagickAppInit.$(OBJEXT) generic_TclMagick_OBJECTS = $(am_generic_TclMagick_OBJECTS) @@ -193,8 +184,7 @@ am__maybe_remake_depfiles = depfiles am__depfiles_remade = generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Po \ generic/$(DEPDIR)/TclMagick_la-TclMagick.Plo \ - generic/$(DEPDIR)/TkMagick_la-TkMagick.Plo \ - generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Plo + generic/$(DEPDIR)/TkMagick_la-TkMagick.Plo am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -215,13 +205,9 @@ am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(generic_TclMagick_la_SOURCES) \ - $(generic_TkMagick_la_SOURCES) \ - $(generic_libttkcommon_la_SOURCES) \ - $(generic_TclMagick_SOURCES) + $(generic_TkMagick_la_SOURCES) $(generic_TclMagick_SOURCES) DIST_SOURCES = $(generic_TclMagick_la_SOURCES) \ - $(generic_TkMagick_la_SOURCES) \ - $(generic_libttkcommon_la_SOURCES) \ - $(generic_TclMagick_SOURCES) + $(generic_TkMagick_la_SOURCES) $(generic_TclMagick_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -482,18 +468,14 @@ # Put this in its own package directory. generic_lib_magickdir = @libdir@/TclMagick@VERSION@ -generic_lib_magick_LTLIBRARIES = generic/libttkcommon.la generic/TclMagick.la generic/TkMagick.la -generic_libttkcommon_la_SOURCES = generic/libttkcommon.c generic/libttkcommon.h -generic_libttkcommon_la_LDFLAGS = @GM_LDFLAGS@ -no-undefined -generic_libttkcommon_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ @GM_LIBS@ -generic_libttkcommon_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ +generic_lib_magick_LTLIBRARIES = generic/TclMagick.la generic/TkMagick.la generic_TclMagick_la_SOURCES = generic/TclMagick.c generic/TclMagick.h generic/libttkcommon.h generic_TclMagick_la_LDFLAGS = @GM_LDFLAGS@ -L$(generic_lib_magickdir) -no-undefined -module -generic_TclMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIBS@ @TCL_LIBS@ @GM_LIBS@ generic/libttkcommon.la +generic_TclMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TCL_LIBS@ @TCL_LIBS@ @GM_LIBS@ generic_TclMagick_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ generic_TkMagick_la_SOURCES = generic/TkMagick.c generic/TclMagick.h generic/libttkcommon.h generic_TkMagick_la_LDFLAGS = @GM_LDFLAGS@ -L$(generic_lib_magickdir) -no-undefined -module -generic_TkMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TK_STUB_LIB_SPEC@ @TCL_LIBS@ @TK_LIBS@ @GM_LIBS@ generic/libttkcommon.la +generic_TkMagick_la_LIBADD = @TCL_STUB_LIB_SPEC@ @TK_STUB_LIB_SPEC@ @TCL_LIB_SPEC@ @TCL_LIBS@ @TK_LIB_SPEC@ @TK_LIBS@ @GM_LIBS@ generic_TkMagick_la_CPPFLAGS = -Igeneric/ @TCL_INCLUDES@ @GM_CPPFLAGS@ @TK_INCLUDES@ @TK_XINCLUDES@ # A TclMagick executable (not installed) @@ -637,11 +619,6 @@ generic/TkMagick.la: $(generic_TkMagick_la_OBJECTS) $(generic_TkMagick_la_DEPENDENCIES) $(EXTRA_generic_TkMagick_la_DEPENDENCIES) generic/$(am__dirstamp) $(AM_V_CCLD)$(generic_TkMagick_la_LINK) -rpath $(generic_lib_magickdir) $(generic_TkMagick_la_OBJECTS) $(generic_TkMagick_la_LIBADD) $(LIBS) -generic/libttkcommon_la-libttkcommon.lo: generic/$(am__dirstamp) \ - generic/$(DEPDIR)/$(am__dirstamp) - -generic/libttkcommon.la: $(generic_libttkcommon_la_OBJECTS) $(generic_libttkcommon_la_DEPENDENCIES) $(EXTRA_generic_libttkcommon_la_DEPENDENCIES) generic/$(am__dirstamp) - $(AM_V_CCLD)$(generic_libttkcommon_la_LINK) -rpath $(generic_lib_magickdir) $(generic_libttkcommon_la_OBJECTS) $(generic_libttkcommon_la_LIBADD) $(LIBS) generic/TclMagick-TclMagickAppInit.$(OBJEXT): generic/$(am__dirstamp) \ generic/$(DEPDIR)/$(am__dirstamp) @@ -660,7 +637,6 @@ @AMDEP_TRUE@@am__include@ @am__quote@generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@generic/$(DEPDIR)/TclMagick_la-TclMagick.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@generic/$(DEPDIR)/TkMagick_la-TkMagick.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Plo@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -706,13 +682,6 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(generic_TkMagick_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o generic/TkMagick_la-TkMagick.lo `test -f 'generic/TkMagick.c' || echo '$(srcdir)/'`generic/TkMagick.c -generic/libttkcommon_la-libttkcommon.lo: generic/libttkcommon.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(generic_libttkcommon_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT generic/libttkcommon_la-libttkcommon.lo -MD -MP -MF generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Tpo -c -o generic/libttkcommon_la-libttkcommon.lo `test -f 'generic/libttkcommon.c' || echo '$(srcdir)/'`generic/libttkcommon.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Tpo generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='generic/libttkcommon.c' object='generic/libttkcommon_la-libttkcommon.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(generic_libttkcommon_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o generic/libttkcommon_la-libttkcommon.lo `test -f 'generic/libttkcommon.c' || echo '$(srcdir)/'`generic/libttkcommon.c - generic/TclMagick-TclMagickAppInit.o: generic/TclMagickAppInit.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(generic_TclMagick_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT generic/TclMagick-TclMagickAppInit.o -MD -MP -MF generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Tpo -c -o generic/TclMagick-TclMagickAppInit.o `test -f 'generic/TclMagickAppInit.c' || echo '$(srcdir)/'`generic/TclMagickAppInit.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Tpo generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Po @@ -1015,7 +984,6 @@ -rm -f generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Po -rm -f generic/$(DEPDIR)/TclMagick_la-TclMagick.Plo -rm -f generic/$(DEPDIR)/TkMagick_la-TkMagick.Plo - -rm -f generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Plo -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-libtool distclean-tags @@ -1067,7 +1035,6 @@ -rm -f generic/$(DEPDIR)/TclMagick-TclMagickAppInit.Po -rm -f generic/$(DEPDIR)/TclMagick_la-TclMagick.Plo -rm -f generic/$(DEPDIR)/TkMagick_la-TkMagick.Plo - -rm -f generic/$(DEPDIR)/libttkcommon_la-libttkcommon.Plo -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -1124,7 +1091,12 @@ cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-pixel.tcl` cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-draw.tcl` cd $(abs_srcdir)/generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-bmp-compare.tcl` -# cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-wand.tcl + +check: + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-wand.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-pixel.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-draw.tcl + cd $(abs_srcdir)/generic && $(abs_builddir)/generic/TclMagick $(abs_srcdir)/tests/test-bmp-compare.tcl #test: # cd generic && $(TCLSH) `@CYGPATH@ $(srcdir)/tests/test-wand.tcl` $(TESTFLAGS) \ diff -r b99b057947ca -r 81eb6070fb80 TclMagick/generic/TclMagick.c --- a/TclMagick/generic/TclMagick.c Sun Sep 29 09:36:36 2024 -0500 +++ b/TclMagick/generic/TclMagick.c Wed Oct 02 09:07:23 2024 -0500 @@ -10,10 +10,14 @@ #include <string.h> #include <stdlib.h> +#define NEED_STATIC_FUNCS 1 + #include "libttkcommon.h" #include "TclMagick.h" #include <wand/magick_wand.h> +static TMHT TM = {0}; + static char *getMagickObjName(TclMagickObj *mPtr); static TclMagickObj *newMagickObj(Tcl_Interp *interp, int type, void *wandPtr, char *name); @@ -29,25 +33,56 @@ #define MAGICK_DEBUG /**********************************************************************/ -extern TMHT TM; -extern CONST char* objTypeNames[]; static Tcl_ObjCmdProc magickCmd; static Tcl_CmdDeleteProc magickObjDeleteCmd; static Tcl_ObjCmdProc wandObjCmd; static Tcl_ObjCmdProc pixelObjCmd; static Tcl_ObjCmdProc drawObjCmd; +static MagickWand *findMagickWand(Tcl_Interp *interp, char *name) +{ + MagickWand *wandPtr = (MagickWand *)NULL; + TclMagickObj *mPtr = findMagickObj(interp, TM_TYPE_WAND, name); + if( mPtr != NULL ) { + wandPtr = (MagickWand *)mPtr->wandPtr; + } + return wandPtr; +} + +static DrawingWand *findDrawingWand(Tcl_Interp *interp, char *name) +{ + DrawingWand *wandPtr = (DrawingWand *)NULL; + TclMagickObj *mPtr = findMagickObj(interp, TM_TYPE_DRAWING, name); + if( mPtr != NULL ) { + wandPtr = (DrawingWand *)mPtr->wandPtr; + } + return wandPtr; +} + +static PixelWand *findPixelWand(Tcl_Interp *interp, char *name) +{ + PixelWand *wandPtr = (PixelWand *) NULL; + TclMagickObj *mPtr = findMagickObj(interp, TM_TYPE_PIXEL, name); + if( mPtr != NULL ) { + wandPtr = (PixelWand *)mPtr->wandPtr; + } + return wandPtr; +} + /*---------------------------------------------------------------------- * Return the name of a TclMagickObj *---------------------------------------------------------------------- */ static char *getMagickObjName(TclMagickObj *mPtr) { - if( mPtr == NULL ) { - return (char *)NULL; - } else { - return (char *)Tcl_GetHashKey(&TM.hashTable, mPtr->hashPtr); - } + char *ObjName = (char *)NULL; + if( mPtr != (TclMagickObj *) NULL) { + assert(TM_P->signature1 == TCL_MAGICK_SIGNATURE); + assert(TM_P->signature2 == TCL_MAGICK_SIGNATURE); + + ObjName = (char *)Tcl_GetHashKey(&TM_P->hashTable, mPtr->hashPtr); + } + return ObjName; } /*---------------------------------------------------------------------- @@ -147,10 +182,13 @@ * Create the hash table entry * Delete already existing object */ - hPtr = Tcl_CreateHashEntry( &TM.hashTable, name, &isNew ); + assert(TM_P->signature1 == TCL_MAGICK_SIGNATURE); + assert(TM_P->signature2 == TCL_MAGICK_SIGNATURE); + + hPtr = Tcl_CreateHashEntry( &TM_P->hashTable, name, &isNew ); if( ! isNew ) { deleteMagickObj(Tcl_GetHashValue(hPtr)); - hPtr = Tcl_CreateHashEntry( &TM.hashTable, name, &isNew ); + hPtr = Tcl_CreateHashEntry( &TM_P->hashTable, name, &isNew ); } Tcl_SetHashValue(hPtr, mPtr); @@ -214,7 +252,7 @@ */ TclMagickObj *findMagickObj(Tcl_Interp *interp, int type, char *name) { - Tcl_HashEntry *hPtr = Tcl_FindHashEntry( &TM.hashTable, name ); + Tcl_HashEntry *hPtr = Tcl_FindHashEntry( &TM_P->hashTable, name ); TclMagickObj *mPtr; if( hPtr == NULL ) { @@ -363,7 +401,7 @@ return TCL_ERROR; } } - hPtr = Tcl_FirstHashEntry(&TM.hashTable, &search); + hPtr = Tcl_FirstHashEntry(&TM_P->hashTable, &search); for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { mPtr = Tcl_GetHashValue(hPtr); if( (type == TM_TYPE_ANY) || (type == mPtr->type) ) { @@ -1130,6 +1168,9 @@ TclMagickObj *magickPtr = (TclMagickObj *) clientData; MagickWand *wandPtr = (MagickWand *) magickPtr->wandPtr; + assert(TM_P->signature1 == TCL_MAGICK_SIGNATURE); + assert(TM_P->signature2 == TCL_MAGICK_SIGNATURE); + #ifdef MAGICK_DEBUG /* * Verify subCmds table size @@ -6241,6 +6282,9 @@ TclMagickObj *magickPtr = (TclMagickObj *) clientData; DrawingWand *wandPtr = (DrawingWand *) magickPtr->wandPtr; + assert(TM_P->signature1 == TCL_MAGICK_SIGNATURE); + assert(TM_P->signature2 == TCL_MAGICK_SIGNATURE); + #ifdef MAGICK_DEBUG /* * Verify subCmds table size @@ -8189,14 +8233,21 @@ ClientData data ) // Tcl Interpreter which is exiting { (void) data; - if ( TM.initialized ) { + if ( TM_P->initialized ) { DestroyMagick(); - TM.initialized = 0; + TM_P->initialized = 0; + memset(TM_P, 0, sizeof(*TM_P)); + /* + * De-register TM_P address for use by the TkMagick module + * + */ + Tcl_UnsetVar(data, TCL_MAGICK_OBJ_VAR, TCL_GLOBAL_ONLY); } } EXPORT(int, Tclmagick_Init)(Tcl_Interp *interp) { + char TM_P_AddrHex[24]; #ifdef USE_TCL_STUBS if (Tcl_InitStubs(interp, "8", 0) == NULL) { return TCL_ERROR; @@ -8205,17 +8256,20 @@ /* * Initialize global variables */ - if ( ! TM.initialized ) { - memset(&TM, 0, sizeof(TM)); + TM_P = &TM; + if ( ! TM_P->initialized ) { + /* memset(TM_P, 0, sizeof(*TM_P)); */ /* * Create Exit handler, hash table */ Tcl_CreateExitHandler(tmExitHandler,(int *) interp); - Tcl_InitHashTable(&TM.hashTable, TCL_STRING_KEYS); + Tcl_InitHashTable(&TM_P->hashTable, TCL_STRING_KEYS); InitializeMagick(Tcl_GetString(Tcl_FSGetCwd(interp))); - TM.initialized = 1; + TM_P->initialized = 1; + TM_P->signature1 = TCL_MAGICK_SIGNATURE; + TM_P->signature2 = TCL_MAGICK_SIGNATURE; } /* * Create commands per interpreter @@ -8225,6 +8279,13 @@ if ( Tcl_PkgProvide(interp,"TclMagick", VERSION) != TCL_OK ) { return TCL_ERROR; } + /* + * Register TM_P address for use by the TkMagick module + * + */ + (void) snprintf(TM_P_AddrHex, sizeof(TM_P_AddrHex), "%p", TM_P); + /* fprintf(stderr,"TclMagick TM_P_AddrHex=%s\n", TM_P_AddrHex); */ + Tcl_SetVar(interp, TCL_MAGICK_OBJ_VAR, TM_P_AddrHex, TCL_GLOBAL_ONLY); return TCL_OK; } diff -r b99b057947ca -r 81eb6070fb80 TclMagick/generic/TkMagick.c --- a/TclMagick/generic/TkMagick.c Sun Sep 29 09:36:36 2024 -0500 +++ b/TclMagick/generic/TkMagick.c Wed Oct 02 09:07:23 2024 -0500 @@ -4,10 +4,14 @@ /* $Id$ */ +#include <string.h> + #include <tk.h> + +#define NEED_STATIC_FUNCS 1 + #include "libttkcommon.h" #include "TclMagick.h" -#include <string.h> #include <wand/magick_wand.h>