summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tk.decls9
-rw-r--r--generic/tkConsole.c126
-rw-r--r--generic/tkDecls.h18
-rw-r--r--generic/tkInt.h4
-rw-r--r--generic/tkMain.c6
-rw-r--r--generic/tkStubInit.c4
-rw-r--r--mac/tkMacAppInit.c6
-rw-r--r--win/winMain.c8
8 files changed, 111 insertions, 70 deletions
diff --git a/generic/tk.decls b/generic/tk.decls
index 9fb67fd..6f8eb13 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tk.decls,v 1.3 1999/04/16 01:51:09 stanton Exp $
+# RCS: @(#) $Id: tk.decls,v 1.4 1999/04/28 18:18:06 redman Exp $
library tk
@@ -1032,6 +1032,13 @@ declare 214 generic {
Tk_SavedOptions *savePtr, int *maskPtr)
}
+declare 215 generic {
+ void Tk_InitConsoleChannels(Tcl_Interp *interp)
+}
+
+declare 216 generic {
+ int Tk_CreateConsoleWindow(Tcl_Interp *interp)
+}
# Define the platform specific public Tk interface. These functions are
# only available on the designated platform.
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index cbbef79..ed7bab8 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkConsole.c,v 1.5 1999/04/16 01:51:13 stanton Exp $
+ * RCS: @(#) $Id: tkConsole.c,v 1.6 1999/04/28 18:18:06 redman Exp $
*/
#include "tk.h"
@@ -33,6 +33,13 @@ typedef struct ThreadSpecificData {
Tcl_Interp *gStdoutInterp;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
+static int consoleInitialized = 0;
+
+/*
+ * The Mutex below is used to lock access to the consoleIntialized flag
+ */
+
+TCL_DECLARE_MUTEX(consoleMutex)
/*
* Forward declarations for procedures defined later in this file:
@@ -40,8 +47,6 @@ static Tcl_ThreadDataKey dataKey;
* The first three will be used in the tk app shells...
*/
-void TkConsoleCreate_ _ANSI_ARGS_((void));
-int TkConsoleInit _ANSI_ARGS_((Tcl_Interp *interp));
void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp,
int devId, char *buffer, long size));
@@ -84,7 +89,7 @@ static Tcl_ChannelType consoleChannelType = {
/*
*----------------------------------------------------------------------
*
- * TkConsoleCreate, TkConsoleCreate_ --
+ * Tk_InitConsoleChannels --
*
* Create the console channels and install them as the standard
* channels. All I/O will be discarded until TkConsoleInit is
@@ -101,71 +106,86 @@ static Tcl_ChannelType consoleChannelType = {
*/
void
-TkConsoleCreate()
-{
- /*
- * This function is being diabled so we don't end up calling it
- * twice. Once from WinMain() and once from Tk_MainEx(). The real
- * function is now tkCreateConsole_ and is only called from Tk_MainEx.
- * All of this is an ugly hack.
- */
-}
-
-void
-TkConsoleCreate_()
+Tk_InitConsoleChannels(interp)
+ Tcl_Interp *interp;
{
Tcl_Channel consoleChannel;
/*
- * check for STDIN, otherwise create it
+ * Ensure that we are getting the matching version of Tcl. This is
+ * really only an issue when Tk is loaded dynamically.
*/
- if (Tcl_GetStdChannel(TCL_STDIN) == NULL) {
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console0",
- (ClientData) TCL_STDIN, TCL_READABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- Tcl_SetChannelOption(NULL, consoleChannel, "-encoding", "utf-8");
- }
- Tcl_SetStdChannel(consoleChannel, TCL_STDIN);
+ if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) {
+ return;
}
- /*
- * check for STDOUT, otherwise create it
- */
-
- if (Tcl_GetStdChannel(TCL_STDOUT) == NULL) {
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console1",
- (ClientData) TCL_STDOUT, TCL_WRITABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- Tcl_SetChannelOption(NULL, consoleChannel, "-encoding", "utf-8");
+ Tcl_MutexLock(&consoleMutex);
+ if (!consoleInitialized) {
+
+ consoleInitialized = 1;
+
+ /*
+ * check for STDIN, otherwise create it
+ */
+
+ if (Tcl_GetStdChannel(TCL_STDIN) == NULL) {
+ consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console0",
+ (ClientData) TCL_STDIN, TCL_READABLE);
+ if (consoleChannel != NULL) {
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-translation", "lf");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-buffering", "none");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(consoleChannel, TCL_STDIN);
}
- Tcl_SetStdChannel(consoleChannel, TCL_STDOUT);
- }
- /*
- * check for STDERR, otherwise create it
- */
-
- if (Tcl_GetStdChannel(TCL_STDERR) == NULL) {
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console2",
- (ClientData) TCL_STDERR, TCL_WRITABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- Tcl_SetChannelOption(NULL, consoleChannel, "-encoding", "utf-8");
+ /*
+ * check for STDOUT, otherwise create it
+ */
+
+ if (Tcl_GetStdChannel(TCL_STDOUT) == NULL) {
+ consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console1",
+ (ClientData) TCL_STDOUT, TCL_WRITABLE);
+ if (consoleChannel != NULL) {
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-translation", "lf");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-buffering", "none");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(consoleChannel, TCL_STDOUT);
+ }
+
+ /*
+ * check for STDERR, otherwise create it
+ */
+
+ if (Tcl_GetStdChannel(TCL_STDERR) == NULL) {
+ consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console2",
+ (ClientData) TCL_STDERR, TCL_WRITABLE);
+ if (consoleChannel != NULL) {
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-translation", "lf");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-buffering", "none");
+ Tcl_SetChannelOption(NULL, consoleChannel,
+ "-encoding", "utf-8");
+ }
+ Tcl_SetStdChannel(consoleChannel, TCL_STDERR);
}
- Tcl_SetStdChannel(consoleChannel, TCL_STDERR);
}
+ Tcl_MutexUnlock(&consoleMutex);
}
/*
*----------------------------------------------------------------------
*
- * TkConsoleInit --
+ * Tk_CreateConsoleWindow --
*
* Initialize the console. This code actually creates a new
* application and associated interpreter. This effectivly hides
@@ -181,7 +201,7 @@ TkConsoleCreate_()
*/
int
-TkConsoleInit(interp)
+Tk_CreateConsoleWindow(interp)
Tcl_Interp *interp; /* Interpreter to use for prompting. */
{
Tcl_Interp *consoleInterp;
diff --git a/generic/tkDecls.h b/generic/tkDecls.h
index f0bf66f..8051955 100644
--- a/generic/tkDecls.h
+++ b/generic/tkDecls.h
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkDecls.h,v 1.3 1999/04/16 01:51:13 stanton Exp $
+ * RCS: @(#) $Id: tkDecls.h,v 1.4 1999/04/28 18:18:06 redman Exp $
*/
#ifndef _TKDECLS
@@ -742,6 +742,12 @@ EXTERN int Tk_SetOptions _ANSI_ARGS_((Tcl_Interp * interp,
int objc, Tcl_Obj *CONST objv[],
Tk_Window tkwin, Tk_SavedOptions * savePtr,
int * maskPtr));
+/* 215 */
+EXTERN void Tk_InitConsoleChannels _ANSI_ARGS_((
+ Tcl_Interp * interp));
+/* 216 */
+EXTERN int Tk_CreateConsoleWindow _ANSI_ARGS_((
+ Tcl_Interp * interp));
typedef struct TkStubHooks {
struct TkPlatStubs *tkPlatStubs;
@@ -969,6 +975,8 @@ typedef struct TkStubs {
void (*tk_MainEx) _ANSI_ARGS_((int argc, char ** argv, Tcl_AppInitProc * appInitProc, Tcl_Interp * interp)); /* 212 */
void (*tk_RestoreSavedOptions) _ANSI_ARGS_((Tk_SavedOptions * savePtr)); /* 213 */
int (*tk_SetOptions) _ANSI_ARGS_((Tcl_Interp * interp, char * recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *CONST objv[], Tk_Window tkwin, Tk_SavedOptions * savePtr, int * maskPtr)); /* 214 */
+ void (*tk_InitConsoleChannels) _ANSI_ARGS_((Tcl_Interp * interp)); /* 215 */
+ int (*tk_CreateConsoleWindow) _ANSI_ARGS_((Tcl_Interp * interp)); /* 216 */
} TkStubs;
extern TkStubs *tkStubsPtr;
@@ -1839,6 +1847,14 @@ extern TkStubs *tkStubsPtr;
#define Tk_SetOptions \
(tkStubsPtr->tk_SetOptions) /* 214 */
#endif
+#ifndef Tk_InitConsoleChannels
+#define Tk_InitConsoleChannels \
+ (tkStubsPtr->tk_InitConsoleChannels) /* 215 */
+#endif
+#ifndef Tk_CreateConsoleWindow
+#define Tk_CreateConsoleWindow \
+ (tkStubsPtr->tk_CreateConsoleWindow) /* 216 */
+#endif
#endif /* defined(USE_TK_STUBS) && !defined(USE_TK_STUB_PROCS) */
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 2372a1e..6c6dc42 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: $Id: tkInt.h,v 1.12 1999/04/21 21:53:26 rjohnson Exp $
+ * RCS: $Id: tkInt.h,v 1.13 1999/04/28 18:18:06 redman Exp $
*/
#ifndef _TKINT
@@ -984,7 +984,7 @@ EXTERN int Tk_WinfoObjCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Obj *CONST objv[]));
EXTERN int Tk_WmCmd _ANSI_ARGS_((ClientData clientData,
Tcl_Interp *interp, int argc, char **argv));
-int TkConsoleInit _ANSI_ARGS_((Tcl_Interp *interp));
+
void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp,
int devId, char *buffer, long size));
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 9502926..ce33f8a 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMain.c,v 1.4 1999/04/16 01:51:19 stanton Exp $
+ * RCS: @(#) $Id: tkMain.c,v 1.5 1999/04/28 18:18:06 redman Exp $
*/
#include <ctype.h>
@@ -60,8 +60,6 @@ extern char * strrchr _ANSI_ARGS_((CONST char *string, int c));
extern void TkpDisplayWarning _ANSI_ARGS_((char *msg,
char *title));
-extern void TkConsoleCreate_ _ANSI_ARGS_((void));
-
/*
* Forward declarations for procedures defined later in this file.
*/
@@ -125,7 +123,7 @@ Tk_MainEx(argc, argv, appInitProc, interp)
tsdPtr->interp = interp;
#if (defined(__WIN32__) || defined(MAC_TCL))
- TkConsoleCreate_();
+ Tk_InitConsoleChannels(interp);
#endif
#ifdef TCL_MEM_DEBUG
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index 7daa2a4..536d688 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkStubInit.c,v 1.6 1999/04/24 01:50:50 stanton Exp $
+ * RCS: @(#) $Id: tkStubInit.c,v 1.7 1999/04/28 18:18:07 redman Exp $
*/
#include "tkInt.h"
@@ -784,6 +784,8 @@ TkStubs tkStubs = {
Tk_MainEx, /* 212 */
Tk_RestoreSavedOptions, /* 213 */
Tk_SetOptions, /* 214 */
+ Tk_InitConsoleChannels, /* 215 */
+ Tk_CreateConsoleWindow, /* 216 */
};
/* !END!: Do not edit above this line. */
diff --git a/mac/tkMacAppInit.c b/mac/tkMacAppInit.c
index 16e83c0..43d3371 100644
--- a/mac/tkMacAppInit.c
+++ b/mac/tkMacAppInit.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkMacAppInit.c,v 1.8 1999/04/16 01:51:29 stanton Exp $
+ * RCS: @(#) $Id: tkMacAppInit.c,v 1.9 1999/04/28 18:18:07 redman Exp $
*/
#include <Gestalt.h>
@@ -54,8 +54,6 @@ short SIOUXHandleOneEvent _ANSI_ARGS_((EventRecord *event));
* Prototypes for functions from the tkConsole.c file.
*/
-EXTERN void TkConsoleCreate _ANSI_ARGS_((void));
-EXTERN int TkConsoleInit _ANSI_ARGS_((Tcl_Interp *interp));
EXTERN void TkConsolePrint _ANSI_ARGS_((Tcl_Interp *interp,
int devId, char *buffer, long size));
/*
@@ -311,7 +309,7 @@ SetupMainInterp(
if (strcmp(Tcl_GetVar(interp, "tcl_interactive", TCL_GLOBAL_ONLY), "1")
== 0) {
- if (TkConsoleInit(interp) == TCL_ERROR) {
+ if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
goto error;
}
}
diff --git a/win/winMain.c b/win/winMain.c
index 79f8f96..54cda5f 100644
--- a/win/winMain.c
+++ b/win/winMain.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: winMain.c,v 1.6 1999/04/16 01:51:55 stanton Exp $
+ * RCS: @(#) $Id: winMain.c,v 1.7 1999/04/28 18:18:07 redman Exp $
*/
#include <tk.h>
@@ -95,7 +95,7 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
/*
* Create the console channels and install them as the standard
- * channels. All I/O will be discarded until TkConsoleInit is
+ * channels. All I/O will be discarded until Tk_CreateConsoleWindow is
* called to attach the console to a text widget.
*/
@@ -143,7 +143,7 @@ Tcl_AppInit(interp)
*/
if (consoleRequired) {
- if (TkConsoleInit(interp) == TCL_ERROR) {
+ if (Tk_CreateConsoleWindow(interp) == TCL_ERROR) {
goto error;
}
}
@@ -366,7 +366,7 @@ int main(int argc, char **argv)
/*
* Create the console channels and install them as the standard
- * channels. All I/O will be discarded until TkConsoleInit is
+ * channels. All I/O will be discarded until Tk_CreateConsoleWindow is
* called to attach the console to a text widget.
*/