
TCLX_PATCHES -   02/13/2000

These patches to TclX8.2.0 form the beginning of Stubs-support
for TclX. Implemented are:
- Some fixes in the use of Tcl_InitStubs().
- libtclx8.2.so is now compiled with -DUSE_TCL_STUBS
  and linked with the stub library.
- A few other fixes, such as header-file ordering in tclXfilescan.c
  and a (char *) cast. Those two fixes are necessary only in
  combination with the 8.2.x plus-patch, and have no
  other side-effects.

Still missing:
- TclX should export its own stub-table, and provide its
  own stub-library (libtclxstub8.2.a) to be picked up by
  libtkx8.2.so
- libtkx8.2.so should be linked with libtclstub8.2.a,
  libtclxstub8.2.a and libtkstub8.2.a

This partial implementation is sufficient for me at this
moment. Later it will be implemented further.

If you are using Solaris, don't be surprised if the patch utility does not
work. This is a known problem. Better install GNU patch version 2.1 or later.

*** pluspatch.orig	Sun Feb 13 21:07:12 2000
--- pluspatch	Sun Feb 13 21:06:53 2000
***************
*** 0 ****
--- 1,55 ----
+ #!/bin/sh
+ # The next line restarts using tclsh8.2 \
+ exec tclsh8.2 $0 ${1+"$@"}
+ 
+ set dirs [list . ./unix ./tcl/unix ./tcl/generic ./tk/unix ./tk/generic]
+ set package "+"
+ set version "8.2.0"
+ set date [clock format [clock seconds] -format "%m/%d/%Y"]
+ 
+ #
+ # This is a tcl-script that will search a list of directories
+ # for ".orig"-files. For all of these it will make a "diff",
+ # and create a patch-file.
+ #
+ #	Written by:	Jan Nijtmans
+ #			CMG (Computer Management Group) Arnhem B.V.
+ #			email: j.nijtmans@chello.nl (private)
+ #			       jan.nijtmans@cmg.nl (work)
+ #			url:   http://purl.oclc.org/net/nijtmans/
+ 
+ set patchlevel ""
+ set dfiles ""
+ 
+ set file [open pluspatch.orig w]
+ close $file
+ 
+ foreach dir $dirs {
+     set files [eval exec ls $dir]
+     foreach file $files {
+ 	if {[regexp ".*\.orig" $file]} {
+ 	    set file [file join $dir [string range $file 0 [expr [string length $file]-6]]]
+ 	    lappend dfiles $file.diff
+ 	    set file [string range $file 2 [string length $file]]
+ 	    puts stdout "creating $file.diff"
+ 	    catch "exec diff -c $file.orig $file >$file.diff"
+ 	}
+     }
+ }
+ 
+ puts stdout "creating TCLX_PATCHES"
+ set file [open TCLX_PATCHES w]
+ puts $file ""
+ puts $file "TCLX_PATCHES -   $date"
+ puts $file ""
+ puts $file "This patch file updates from TclX ${version} to TclX ${version}${package}. It should be applied"
+ puts $file "by running the \"patch\" program in the top-level directory of a clean"
+ puts $file "TclX ${version} release, using the command \"patch -p0 <TCLX_PATCHES\""
+ puts $file ""
+ puts $file "If you are using Solaris, don't be surprised if the patch utility does not"
+ puts $file "work. This is a known problem. Better install GNU patch version 2.1 or later."
+ puts $file ""
+ eval exec cat $dfiles >@$file
+ close $file
+ 
+ file delete pluspatch.diff pluspatch.orig
*** unix/Common.mk.in.orig	Mon Feb  7 01:54:02 2000
--- unix/Common.mk.in	Sun Feb 13 20:04:29 2000
***************
*** 122,128 ****
  TCL_DEFS             = @TCL_DEFS@
  TCL_LIBS             = @TCL_LIBS@
  TCL_EXEC_PREFIX      = @TCL_EXEC_PREFIX@
! TCL_SHLIB_CFLAGS     = @TCL_SHLIB_CFLAGS@
  TCL_LD_FLAGS         = @TCL_LD_FLAGS@
  TCL_DL_LIBS          = @TCL_DL_LIBS@
  TCL_SHLIB_LD         = @TCL_SHLIB_LD@
--- 122,128 ----
  TCL_DEFS             = @TCL_DEFS@
  TCL_LIBS             = @TCL_LIBS@
  TCL_EXEC_PREFIX      = @TCL_EXEC_PREFIX@
! TCL_SHLIB_CFLAGS     = @TCL_SHLIB_CFLAGS@ -DUSE_TCL_STUBS
  TCL_LD_FLAGS         = @TCL_LD_FLAGS@
  TCL_DL_LIBS          = @TCL_DL_LIBS@
  TCL_SHLIB_LD         = @TCL_SHLIB_LD@
*** unix/configure.in.orig	Mon Feb  7 01:54:02 2000
--- unix/configure.in	Sun Feb 13 20:04:35 2000
***************
*** 461,510 ****
  AC_SUBST(SHARED_LIBS)
  
  #------------------------------------------------------------------------------
- # Check for Plus patch being installed. Does libtcl.a contains a definition of
- # Tcl_InitStandAlone() and does Tk contain Tk_InitStandAlone.
- #------------------------------------------------------------------------------
- AC_MSG_CHECKING([standalone support of Tcl (Plus patch)])
- if test -f "${TCL_BUILD}/unix/${TCL_STLIB_NAME}"; then
-     x=`nm -p "${TCL_BUILD}/unix/${TCL_STLIB_NAME}" |grep 'Tcl_InitStandAlone'`
-     if test "x$x" != "x"; then
-         # Build variables already set
- 	AC_MSG_RESULT([yes])
-         AC_DEFINE(HAVE_TCL_STANDALONE)
-     else
- 	AC_MSG_RESULT([no])
- 	TCLX_BUILD_STANDALONE=""
- 	TCLX_BUILD_DUMMY_STANDALONE=""
-     fi
- else
-     AC_MSG_RESULT([no])
-     TCLX_BUILD_STANDALONE=""
-     TCLX_BUILD_DUMMY_STANDALONE=""
- fi
- AC_SUBST(TCLX_BUILD_STANDALONE)
- AC_SUBST(TCLX_BUILD_DUMMY_STANDALONE)
- 
- AC_MSG_CHECKING([standalone support of Tk (Plus patch)])
- if test "${TKX_BUILD}" = "YES" -a -f "${TK_BUILD}/unix/${TK_STLIB_NAME}"; then
-     x=`nm -p "${TK_BUILD}/unix/${TK_STLIB_NAME}" |grep 'Tk_InitStandAlone'`
-     if test "x$x" != "x"; then
-         # Build variables already set
- 	AC_MSG_RESULT([yes])
-         AC_DEFINE(HAVE_TK_STANDALONE)
-     else
- 	AC_MSG_RESULT([no])
- 	TKX_BUILD_STANDALONE=""
- 	TKX_BUILD_DUMMY_STANDALONE=""
-     fi
- else
-     AC_MSG_RESULT([no])
-     TKX_BUILD_STANDALONE=""
-     TKX_BUILD_DUMMY_STANDALONE=""
- fi
- AC_SUBST(TKX_BUILD_STANDALONE)
- AC_SUBST(TKX_BUILD_DUMMY_STANDALONE)
- 
- #------------------------------------------------------------------------------
  # Determine if Tcl was built with threading support.
  #------------------------------------------------------------------------------
  SC_ENABLE_THREADS
--- 461,466 ----
*** tcl/unix/Makefile.in.orig	Mon Feb  7 01:53:59 2000
--- tcl/unix/Makefile.in	Sun Feb 13 20:55:39 2000
***************
*** 37,43 ****
  LD_SWITCHES = ${LDFLAGS} ${TCL_LD_FLAGS} ${TCL_LD_SEARCH_FLAGS} \
  	      ${XLDFLAGS} ${XCFLAGS} ${CFLAGS}
  
! LIBS = @SHARED_LIBS@
  
  ALL_LIBS = ${TCLX_BUILD_LIB_SPEC} ${TCL_BUILD_LIB_SPEC} \
  	   ${XLDLIBS} ${TCLX_LIBS} ${TCL_LIBS}
--- 37,43 ----
  LD_SWITCHES = ${LDFLAGS} ${TCL_LD_FLAGS} ${TCL_LD_SEARCH_FLAGS} \
  	      ${XLDFLAGS} ${XCFLAGS} ${CFLAGS}
  
! LIBS = ${TCLX_LD_SEARCH_FLAGS} ${TCL_BUILD_STUB_LIB_SPEC} @SHARED_LIBS@
  
  ALL_LIBS = ${TCLX_BUILD_LIB_SPEC} ${TCL_BUILD_LIB_SPEC} \
  	   ${XLDLIBS} ${TCLX_LIBS} ${TCL_LIBS}
***************
*** 45,50 ****
--- 45,52 ----
  STATIC_LIBS = ${TCLX_STLIB_NAME} ${TCL_UNIX_DIR}/${TCL_STLIB_NAME} \
  	      ${XLDLIBS} ${TCLX_LIBS} ${TCL_LIBS}
  
+ LIB_RUNTIME_DIR = ${TCLX_INST_LIB}
+ 
  #------------------------------------------------------------------------------
  # Source and target macros.
  #
***************
*** 119,128 ****
  HELP_DIR = ${srcbasedir}/tcl/help
  
  TEST_OBJS = tclTest.o tclTestObj.o tclUnixTest.o tclXtest.o \
! 	tclThreadTest.o tclXunixTest.o
  
  TEST_SAOBJS = tclTest.o tclTestObj.o tclUnixTest.o tclXtest.o \
! 	tclThreadTest.o tclXunixTestSA.o
  
  #------------------------------------------------------------------------------
  # Dependencies for generating the libraries and linking the executable.
--- 121,130 ----
  HELP_DIR = ${srcbasedir}/tcl/help
  
  TEST_OBJS = tclTest.o tclTestObj.o tclUnixTest.o tclXtest.o \
! 	tclThreadTest.o tclXunixTest.o tclTestProcBodyObj.o
  
  TEST_SAOBJS = tclTest.o tclTestObj.o tclUnixTest.o tclXtest.o \
! 	tclThreadTest.o tclXunixTestSA.o tclTestProcBodyObj.o
  
  #------------------------------------------------------------------------------
  # Dependencies for generating the libraries and linking the executable.
***************
*** 255,260 ****
--- 257,265 ----
  
  tclThreadTest.o: ${TCL_SRC_DIR}/generic/tclThreadTest.c
  	${CC} -c ${CC_SWITCHES} ${TCL_SRC_DIR}/generic/tclThreadTest.c
+ 
+ tclTestProcBodyObj.o: ${TCL_SRC_DIR}/generic/tclTestProcBodyObj.c
+ 	${CC} -c ${CC_SWITCHES} ${TCL_SRC_DIR}/generic/tclTestProcBodyObj.c
  
  dltest.tmp: dltest
  	touch dltest.tmp
*** tcl/generic/tclExtend.h.orig	Mon Feb  7 01:53:54 2000
--- tcl/generic/tclExtend.h	Sun Feb 13 20:04:35 2000
***************
*** 128,136 ****
  			       int         exact));
  
  EXTERN int
- Tclx_InitStandAlone _ANSI_ARGS_((Tcl_Interp *interp));
- 
- EXTERN int
  Tclxcmd_Init _ANSI_ARGS_((Tcl_Interp *interp));
  
  EXTERN int
--- 128,133 ----
***************
*** 305,313 ****
  
  EXTERN int
  Tkx_Init _ANSI_ARGS_((Tcl_Interp  *interp));
- 
- EXTERN int
- Tkx_InitStandAlone _ANSI_ARGS_((Tcl_Interp *interp));
  
  EXTERN int
  Tkx_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
--- 302,307 ----
*** tcl/generic/tclXfilescan.c.orig	Mon Feb  7 01:53:54 2000
--- tcl/generic/tclXfilescan.c	Sun Feb 13 20:04:35 2000
***************
*** 17,24 ****
   *-----------------------------------------------------------------------------
   */
  
! #include "tclExtdInt.h"
  #include "tclRegexp.h"
  
  /*
   * A scan context describes a collection of match patterns and commands,
--- 17,25 ----
   *-----------------------------------------------------------------------------
   */
  
! #include "tcl.h"
  #include "tclRegexp.h"
+ #include "tclExtdInt.h"
  
  /*
   * A scan context describes a collection of match patterns and commands,
*** tcl/generic/tclXinit.c.orig	Mon Feb  7 01:53:54 2000
--- tcl/generic/tclXinit.c	Sun Feb 13 20:44:06 2000
***************
*** 28,34 ****
   *      default directory does not work.
   *    o [info nameofexectutable]/../../tclX$version/$w/$platform, for
   *      running before installation.  Platform is either "unix" or "win".
!  * The source -rsrc commands are used when TclX has standalone support built
   * in.
   *
   * Parameters:
--- 28,34 ----
   *      default directory does not work.
   *    o [info nameofexectutable]/../../tclX$version/$w/$platform, for
   *      running before installation.  Platform is either "unix" or "win".
!  * The ::wrap::source commands are used when TclX has standalone support built
   * in.
   *
   * Parameters:
***************
*** 58,65 ****
  	}\n\
          set libDir {}\n",
  #ifdef HAVE_TCL_STANDALONE
!        "if ![catch {uplevel #0 source -rsrc ${w}x}] {\n\
! 	    uplevel #0 source -rsrc ${w}x:tclIndex\n\
  	    return\n\
          }\n",
  #endif    
--- 58,65 ----
  	}\n\
          set libDir {}\n",
  #ifdef HAVE_TCL_STANDALONE
!        "if ![catch {uplevel #0 ::wrap::source lib/${w}X$version/${w}x.tcl}] {\n\
! 	    uplevel #0 ::wrap::source lib/${w}X$version/tclIndex\n\
  	    return\n\
          }\n",
  #endif    
***************
*** 362,368 ****
  InitSetup (interp)
      Tcl_Interp *interp;
  {
!     if (Tcl_PkgRequire (interp, "Tcl", TCL_VERSION, 1) == NULL) {
  	return TCL_ERROR;
      }
      if (Tcl_PkgProvide (interp, "Tclx", TCLX_VERSION) != TCL_OK) {
--- 362,368 ----
  InitSetup (interp)
      Tcl_Interp *interp;
  {
!     if (Tcl_PkgRequire (interp, "Tcl", TCLX_VERSION, 0) == NULL) {
  	return TCL_ERROR;
      }
      if (Tcl_PkgProvide (interp, "Tclx", TCLX_VERSION) != TCL_OK) {
***************
*** 394,401 ****
  Tclx_Init (interp)
      Tcl_Interp *interp;
  {
!     if (Tcl_InitStubs(interp, "8.0", 0) == NULL) {
! 	abort();
      }
  
      if (InitSetup (interp) == TCL_ERROR)
--- 394,401 ----
  Tclx_Init (interp)
      Tcl_Interp *interp;
  {
!     if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
! 	return TCL_ERROR;
      }
  
      if (InitSetup (interp) == TCL_ERROR)
*** tcl/generic/tclXlib.c.orig	Mon Feb  7 01:53:54 2000
--- tcl/generic/tclXlib.c	Sun Feb 13 20:49:34 2000
***************
*** 45,56 ****
   */
  #ifdef HAVE_TCL_STANDALONE
  static char autoloadCmd [] =
! "if [catch {source -rsrc autoload}] {\n\
!     source [file join $tclx_library autoload.tcl]\n\
  }";
  #else
  static char autoloadCmd [] =
!     "source [file join $tclx_library autoload.tcl]";
  #endif
  
  /*
--- 45,56 ----
   */
  #ifdef HAVE_TCL_STANDALONE
  static char autoloadCmd [] =
! "if [catch {::wrap::source lib/tclX8.2/autoload.tcl}] {\n\
!     source [list [file join $tclx_library autoload.tcl]];
  }";
  #else
  static char autoloadCmd [] =
!     "source [list [file join $tclx_library autoload.tcl]]";
  #endif
  
  /*
***************
*** 207,213 ****
          goto posixError;
      channel = NULL;
  
!     oldScriptFile = iPtr->scriptFile;
      iPtr->scriptFile = fileName;
      result = Tcl_GlobalEval (interp, cmdBuf.string);
      iPtr->scriptFile = oldScriptFile;
--- 207,213 ----
          goto posixError;
      channel = NULL;
  
!     oldScriptFile = (char *) iPtr->scriptFile;
      iPtr->scriptFile = fileName;
      result = Tcl_GlobalEval (interp, cmdBuf.string);
      iPtr->scriptFile = oldScriptFile;
***************
*** 638,644 ****
      Tcl_DStringInit (&command);
  
      Tcl_DStringAppend (&command, 
! 		       "if [catch {source -rsrc buildidx}] {source [file join $tclx_library buildidx.tcl]};", -1);
      Tcl_DStringAppend (&command, "buildpackageindex ", -1);
      Tcl_DStringAppend (&command, tlibFilePath, -1);
  
--- 638,644 ----
      Tcl_DStringInit (&command);
  
      Tcl_DStringAppend (&command, 
! 		       "if [catch {::wrap::source /lib/tclX8.2/buildidx.tcl}] {source [file join $tclx_library buildidx.tcl]};", -1);
      Tcl_DStringAppend (&command, "buildpackageindex ", -1);
      Tcl_DStringAppend (&command, tlibFilePath, -1);
  
*** tk/generic/tkXinit.c.orig	Mon Feb  7 01:54:00 2000
--- tk/generic/tkXinit.c	Sun Feb 13 20:04:36 2000
***************
*** 36,42 ****
  InitSetup (interp)
      Tcl_Interp  *interp;
  {
!     if (Tcl_PkgRequire (interp, "Tk", TK_VERSION, 1) == NULL) {
   	return TCL_ERROR;
      }
      if (Tcl_PkgRequire (interp, "Tclx", TCLX_VERSION, 1) == NULL) {
--- 36,45 ----
  InitSetup (interp)
      Tcl_Interp  *interp;
  {
!     if (Tcl_InitStubs (interp, TCL_VERSION, 0) == NULL) {
!       return TCL_ERROR;
!     }
!     if (Tk_InitStubs (interp, TK_VERSION, 0) == NULL) {
   	return TCL_ERROR;
      }
      if (Tcl_PkgRequire (interp, "Tclx", TCLX_VERSION, 1) == NULL) {
***************
*** 60,76 ****
  int Tkx_Init (interp)
      Tcl_Interp *interp;
  {
-     /* 
-      * Initialize the stubs before making any calls to Tcl or Tk APIs.
-      */
- 
-     if (Tcl_InitStubs(interp, "8.0", 0) == NULL) {
- 	abort();
-     }
-     if (Tk_InitStubs(interp, "8.0", 0) == NULL) {
- 	abort();
-     }
- 
      if (InitSetup(interp) != TCL_OK) {
  	goto errorExit;
      }
--- 63,68 ----
*** tk/generic/tkXshell.c.orig	Sun Feb 13 20:58:13 2000
--- tk/generic/tkXshell.c	Sun Feb 13 20:59:05 2000
***************
*** 84,91 ****
  extern int		isatty _ANSI_ARGS_((int fd));
  extern char *		strrchr _ANSI_ARGS_((CONST char *string, int c));
  #endif
- extern void		TkpDisplayWarning _ANSI_ARGS_((char *msg,
- 			    char *title));
  
  #ifndef TKX_SHELL
  /*
--- 84,89 ----
