[eggheads-patches] PATCH: set_tcl_vars.diff

Tothwolf tothwolf at concentric.net
Sun Oct 31 13:47:26 CST 1999


set_tcl_vars.diff:
  minor src/Makefile.in changes
  removed useless set_tcl_vars() macro and calls
  added call to Tcl_SetVar in init_tcl() which sets 'tcl_interactive' to 0
  removed old FIXME comment that was a leftover from the cleanup tree
  removed unused var 'tclconfigfile' from configure
  added call to Tcl_InitMemory() in init_tcl()
  init_tcl() now gets argc and argv passed to it from main()
  added call to Tcl_FindExecutable() in init_tcl()

-Toth
-------------- next part --------------
diff -urNPX ../exclude ../eggdrop1.3/Makefile.in ./Makefile.in
--- ../eggdrop1.3/Makefile.in	Wed Oct 27 02:50:35 1999
+++ ./Makefile.in	Sun Oct 31 13:01:43 1999
@@ -13,10 +13,10 @@
 EGGVERSION = @EGGVERSION@
 
 # things you can put here:
-#   -Wall            if you're using gcc and it supports it (configure
-#                      usually detects this anyway now)
+#   -Wall            if you're using gcc and it supports it
+#                    (configure usually detects this anyway now)
 #   -DEBUG_MEM       to be able to debug memory allocation (.debug)
-# this can now be set by using 'make debug'
+#                    this can now be set by using 'make debug' or 'make sdebug'
 CFLGS =
 
 # configure SHOULD set these...you may need to tweak them to get modules
@@ -58,36 +58,33 @@
 TCLLIBFN = @TCLLIBFN@
 
 CFLAGS = @CFLAGS@ -I.. @DEFS@ $(CFLGS)
+DEBCFLAGS = @CFLAGS@ -I.. @DEFS@ -DEBUG_MEM $(CFLGS)
 
 MAKE_MODEGG = $(MAKE) 'CC=$(MOD_CC)' 'LD=$(MOD_LD)' 'STRIP=$(MOD_STRIP)' \
-'RANLIB=$(RANLIB)' 'CFLAGS=$(CFLAGS)' \
-'CPPFLAGS=$(CPPFLAGS)' 'EGGEXEC=$(EGGEXEC)' 'TCLLIB=$(TCLLIB)' \
-'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \
-'EGGBUILD=' 'MODOBJS='
+'RANLIB=$(RANLIB)' 'CFLAGS=$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(DEBCFLAGS)' 'CPPFLAGS=$(CPPFLAGS)' \
+'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \
+'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(debug version)' 'MODOBJS='
 
 MAKE_DEBMODULES = $(MAKE) 'CC=$(SHLIB_CC)' 'LD=$(SHLIB_LD)' \
-'STRIP=touch' 'CFLAGS=-g3 $(CFLAGS) -DEBUG_MEM' 'CPPFLAGS=$(CPPFLAGS)'
+'STRIP=touch' 'CFLAGS=-g3 $(DEBCFLAGS)' 'CPPFLAGS=$(CPPFLAGS)'
 
 MAKE_SDEBUG = $(MAKE) 'CC=$(CC)' 'LD=$(LD) -g' 'STRIP=touch' \
-'RANLIB=$(RANLIB)' 'CFLAGS=-g3 $(CFLAGS) -DSTATIC -DEBUG_MEM' \
-'CPPFLAGS=$(CPPFLAGS)' 'EGGEXEC=$(EGGEXEC)' 'TCLLIB=$(TCLLIB)' \
-'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \
-'EGGBUILD=(static and debug version)' 'MODOBJS=mod/*.o'
+'RANLIB=$(RANLIB)' 'CFLAGS=-g3 $(DEBCFLAGS) -DSTATIC' 'CPPFLAGS=$(CPPFLAGS)' \
+'TCLLIB=$(TCLLIB)' 'TCLLIBFN=$(TCLLIBFN)' 'XREQS=$(XREQS)' 'XLIBS=$(XLIBS)' \
+'EGGEXEC=$(EGGEXEC)' 'EGGBUILD=(static and debug version)' 'MODOBJS=mod/*.o'
 
 MAKE_INSTALL = $(MAKE) 'DEST=$(DEST)'
 
diff -urNPX ../exclude ../eggdrop1.3/configure ./configure
--- ../eggdrop1.3/configure	Sat Oct 30 20:54:07 1999
+++ ./configure	Sun Oct 31 00:19:03 1999
@@ -2829,8 +2829,6 @@
 tclheaderpaths="/usr/local/include /usr/local/pkgs/tcl/include \
 	/usr/include $HOME/include $HOME/tcl/include $HOME"
 
-tclconfigfile="tclConfig.sh"
-
 # Check whether --with-tcllib or --without-tcllib was given.
 if test "${with_tcllib+set}" = set; then
   withval="$with_tcllib"
@@ -3029,7 +3027,7 @@
 fi
 
 echo $ac_n "checking for Tcl library""... $ac_c" 1>&6
-echo "configure:3033: checking for Tcl library" >&5
+echo "configure:3031: checking for Tcl library" >&5
 
 # attempt autodetect for $TCLLIBFN if it's not set
 if test ! "x${TCLLIBFN}" = "x"
@@ -3063,7 +3061,7 @@
 fi
 
 echo $ac_n "checking for Tcl header""... $ac_c" 1>&6
-echo "configure:3067: checking for Tcl header" >&5
+echo "configure:3065: checking for Tcl header" >&5
 
 # attempt autodetect for $TCLINCFN if it's not set
 if test ! "x${TCLINCFN}" = "x"
@@ -3122,7 +3120,7 @@
 
 # check if we found Tcl's version
 echo $ac_n "checking for Tcl version""... $ac_c" 1>&6
-echo "configure:3126: checking for Tcl version" >&5
+echo "configure:3124: checking for Tcl version" >&5
 if test ! "x${TCL_VERSION}" = "x"
 then
   if test ! "x${TCL_PATCH_LEVEL}" = "x"
@@ -3202,7 +3200,7 @@
 
 # check for Tcl_Free()
 echo $ac_n "checking if Tcl library has Tcl_Free""... $ac_c" 1>&6
-echo "configure:3206: checking if Tcl library has Tcl_Free" >&5
+echo "configure:3204: checking if Tcl library has Tcl_Free" >&5
 if eval "test \"`echo '$''{'ac_cv_var_tcl_free'+set}'`\" = set"
 then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3245,7 +3243,7 @@
 
 # check for TclpFinalizeThreadData()
 echo $ac_n "checking if Tcl library has threads""... $ac_c" 1>&6
-echo "configure:3249: checking if Tcl library has threads" >&5
+echo "configure:3247: checking if Tcl library has threads" >&5
 if eval "test \"`echo '$''{'ac_cv_var_tcl_threads'+set}'`\" = set"
 then
   echo $ac_n "(cached) $ac_c" 1>&6
diff -urNPX ../exclude ../eggdrop1.3/configure.in ./configure.in
--- ../eggdrop1.3/configure.in	Sat Oct 30 20:54:07 1999
+++ ./configure.in	Sun Oct 31 00:18:50 1999
@@ -394,8 +394,6 @@
 tclheaderpaths="/usr/local/include /usr/local/pkgs/tcl/include \
 	/usr/include $HOME/include $HOME/tcl/include $HOME"
 
-tclconfigfile="tclConfig.sh"
-
 dnl oohh new configure --variables for those with multiple tcl libs
 AC_ARG_WITH(tcllib, [  --with-tcllib=PATH      full path to tcl library], tcllibname=$withval)
 AC_ARG_WITH(tclinc, [  --with-tclinc=PATH      full path to tcl header], tclincname=$withval)
diff -urNPX ../exclude ../eggdrop1.3/src/botmsg.c ./src/botmsg.c
--- ../eggdrop1.3/src/botmsg.c	Mon Oct 18 14:59:50 1999
+++ ./src/botmsg.c	Sat Oct 30 22:47:31 1999
@@ -885,7 +885,6 @@
   Tcl_SetVar(interp, "_data", msg, 0);
   simple_sprintf(ss, "%d", dcc[idx].sock);
   Tcl_SetVar(interp, "_idx", ss, 0);
-  set_tcl_vars();
   if (Tcl_VarEval(interp, "storenote", " $_from $_to $_data $_idx", NULL) == TCL_OK) {
     if (interp->result && interp->result[0]) {
       /* strncpy(to, interp->result, NOTENAMELEN);
diff -urNPX ../exclude ../eggdrop1.3/src/cmds.c ./src/cmds.c
--- ../eggdrop1.3/src/cmds.c	Tue Oct 26 03:08:40 1999
+++ ./src/cmds.c	Sat Oct 30 22:47:11 1999
@@ -2179,7 +2179,6 @@
     return;
   }
   debug1("tcl: evaluate (.tcl): %s", msg);
-  set_tcl_vars();
   code = Tcl_GlobalEval(interp, msg);
   if (code == TCL_OK)
     dumplots(idx, "Tcl: ", interp->result);
@@ -2198,7 +2197,6 @@
     return;
   }
   putlog(LOG_CMDS, "*", "#%s# set %s", dcc[idx].nick, msg);
-  set_tcl_vars();
   strcpy(s, "set ");
   if (!msg[0]) {
     strcpy(s, "info globals");
diff -urNPX ../exclude ../eggdrop1.3/src/dcc.c ./src/dcc.c
--- ../eggdrop1.3/src/dcc.c	Sat Oct 30 20:54:08 1999
+++ ./src/dcc.c	Sat Oct 30 22:47:26 1999
@@ -1562,7 +1562,6 @@
 {
   char s[11];
 
-  set_tcl_vars();
   sprintf(s, "%d", idx);
   Tcl_SetVar(interp, "_n", s, 0);
   Tcl_SetVar(interp, "_a", args, 0);
@@ -1582,7 +1581,6 @@
   if (!len)
     return;
   dcc[idx].timeval = now;
-  set_tcl_vars();
   if (call_tcl_func(dcc[idx].u.script->command, dcc[idx].sock, buf)) {
     context;
     if ((dcc[idx].sock != oldsock) || (idx>max_dcc))
diff -urNPX ../exclude ../eggdrop1.3/src/dccutil.c ./src/dccutil.c
--- ../eggdrop1.3/src/dccutil.c	Mon Oct 18 14:59:50 1999
+++ ./src/dccutil.c	Sun Oct 31 01:27:56 1999
@@ -76,7 +76,6 @@
   return tot;
 }
 
-/* FIXME: should this be here ? */
 static char SBUF[1024];
 
 /* replace \n with \r\n */
@@ -95,6 +94,7 @@
 }
 
 extern void (*qserver) (int, char *, int);
+
 void dprintf EGG_VARARGS_DEF(int, arg1)
 {
   char *format;
diff -urNPX ../exclude ../eggdrop1.3/src/main.c ./src/main.c
--- ../eggdrop1.3/src/main.c	Wed Oct 27 15:17:41 1999
+++ ./src/main.c	Sun Oct 31 00:52:15 1999
@@ -539,7 +539,8 @@
 #include "mod/static.h"
 #endif
 int init_mem(), init_dcc_max(), init_userent(), init_misc(), init_bots(),
- init_net(), init_modules(), init_tcl(), init_language(int);
+ init_net(), init_modules(), init_tcl(int, char **),
+ init_language(int);
 
 int main(int argc, char **argv)
 {
@@ -616,7 +617,7 @@
   init_bots();
   init_net();
   init_modules();
-  init_tcl();
+  init_tcl(argc, argv);
   init_language(0);
 #ifdef STATIC
   link_statics();
@@ -893,7 +894,7 @@
 	flushlogs();
 	context;
 	kill_tcl();
-	init_tcl();
+	init_tcl(argc, argv);
 	init_language(0);
 	x = p->funcs[MODCALL_START];
 	x(0);
diff -urNPX ../exclude ../eggdrop1.3/src/proto.h ./src/proto.h
--- ../eggdrop1.3/src/proto.h	Mon Oct 18 14:59:54 1999
+++ ./src/proto.h	Sat Oct 30 22:46:45 1999
@@ -222,7 +222,6 @@
 void protect_tcl();
 void unprotect_tcl();
 void do_tcl(char *, char *);
-void set_tcl_vars();
 int readtclprog(char *);
 int findidx(int);
 int findanyidx(int);
diff -urNPX ../exclude ../eggdrop1.3/src/tcl.c ./src/tcl.c
--- ../eggdrop1.3/src/tcl.c	Wed Oct 27 15:17:42 1999
+++ ./src/tcl.c	Sun Oct 31 13:07:32 1999
@@ -460,25 +460,44 @@
 
 /* not going through Tcl's crazy main() system (what on earth was he
  * smoking?!) so we gotta initialize the Tcl interpreter */
-void init_tcl()
+void init_tcl(int argc, char **argv)
 {
 #ifndef HAVE_PRE7_5_TCL
   int i;
   char pver[1024] = "";
 #endif
 
-  /* initialize the interpreter */
   context;
+#ifndef HAVE_PRE7_5_TCL
+  /* This is used for 'info nameofexecutable'.
+   * The filename in argv[0] must exist in a directory listed in
+   * the environment variable PATH for it to register anything. */
+  Tcl_FindExecutable(argv[0]);
+#endif
+
+  /* initialize the interpreter */
   interp = Tcl_CreateInterp();
   Tcl_Init(interp);
+
+#ifdef EBUG_MEM
+  /* initialize Tcl's memory debugging if we have it */
+  Tcl_InitMemory(interp);
+#endif
+
+  /* set Tcl variable tcl_interactive to 0 */
+  Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
+
+  /* initialize binds and traces */
   init_bind();
   init_traces();
+
   /* add new commands */
+  Tcl_CreateCommand(interp, "logfile", tcl_logfile, NULL, NULL);
   /* isnt this much neater :) */
   add_tcl_commands(tcluser_cmds);
   add_tcl_commands(tcldcc_cmds);
   add_tcl_commands(tclmisc_cmds);
-  Tcl_CreateCommand(interp, "logfile", tcl_logfile, NULL, NULL);
+
 #ifndef HAVE_PRE7_5_TCL
   /* add eggdrop to Tcl's package list */
   for (i = 0; i <= strlen(egg_version); i++) {
@@ -502,7 +521,6 @@
     if (f != NULL)
       fprintf(f, "eval: %s\n", script);
   }
-  set_tcl_vars();
   context;
   code = Tcl_Eval(interp, script);
   if (debug_tcl && (f != NULL)) {
@@ -522,7 +540,6 @@
   int code;
   FILE *f;
 
-  set_tcl_vars();
   f = fopen(fname, "r");
   if (f == NULL)
     return 0;
diff -urNPX ../exclude ../eggdrop1.3/src/tclegg.h ./src/tclegg.h
--- ../eggdrop1.3/src/tclegg.h	Wed Jun 23 14:51:32 1999
+++ ./src/tclegg.h	Sat Oct 30 23:38:48 1999
@@ -134,7 +134,4 @@
 void add_tcl_ints(tcl_ints *);
 void rem_tcl_ints(tcl_ints *);
 
-/* set Tcl variables to match eggdrop internal variables */
-#define set_tcl_vars() \
-Tcl_SetVar(interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY)
 #endif
diff -urNPX ../exclude ../eggdrop1.3/src/tclhash.c ./src/tclhash.c
--- ../eggdrop1.3/src/tclhash.c	Thu Oct  7 18:12:02 1999
+++ ./src/tclhash.c	Sat Oct 30 22:47:19 1999
@@ -539,7 +539,6 @@
     if (f != NULL)
       fprintf(f, "eval: %s%s\n", proc, param);
   }
-  set_tcl_vars();
   context;
   x = Tcl_VarEval(interp, proc, param, NULL);
   context;
@@ -829,7 +828,6 @@
   context;
   simple_sprintf(s, "%d", idx);
   Tcl_SetVar(interp, "_n", s, 0);
-  set_tcl_vars();
   context;
   x = Tcl_VarEval(interp, cmd, " $_n", NULL);
   context;


More information about the Patches mailing list