summaryrefslogtreecommitdiffstats
path: root/generic/tclMain.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2008-12-15 15:48:33 (GMT)
committerdgp <dgp@users.sourceforge.net>2008-12-15 15:48:33 (GMT)
commitf846544ae625a6ea36e4a75e8f5f6caf47d6242c (patch)
tree64730fb8e40e8e03e2e6c15b333bf5dba194866e /generic/tclMain.c
parenta9acaa7613d6dc4d271a5af9d80f4a36b647b898 (diff)
downloadtcl-f846544ae625a6ea36e4a75e8f5f6caf47d6242c.zip
tcl-f846544ae625a6ea36e4a75e8f5f6caf47d6242c.tar.gz
tcl-f846544ae625a6ea36e4a75e8f5f6caf47d6242c.tar.bz2
TIP #338 IMPLEMENTATION
* doc/AppInit.c: Made routines Tcl_SetStartupScript and * doc/Tcl_Main.3: Tcl_GetStartupScript public. Removed all * generic/tcl.h: internal stub access to Tcl*Startup* routines, * generic/tclInt.decls: and removed their implementations. Their * generic/tclMain.c: function can now be completely performed with the new public interface. *** POTENTIAL INCOMPATIBILITY for callers of the internal Tcl*Startup* routines. *** * generic/tclIntDecls.h: make genstubs * generic/tclStubInit.c:
Diffstat (limited to 'generic/tclMain.c')
-rw-r--r--generic/tclMain.c147
1 files changed, 29 insertions, 118 deletions
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 4326c3a..f735493 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.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: tclMain.c,v 1.46 2008/10/02 23:36:12 dkf Exp $
+ * RCS: @(#) $Id: tclMain.c,v 1.47 2008/12/15 15:48:33 dgp Exp $
*/
#include "tclInt.h"
@@ -32,8 +32,15 @@
extern CRTIMPORT int isatty(int fd);
-static Tcl_Obj *tclStartupScriptPath = NULL;
-static Tcl_Obj *tclStartupScriptEncoding = NULL;
+typedef struct StartupScript {
+ Tcl_Obj *path; /* The filename of the script for *_Main() routines
+ * to [source] as a startup script, or NULL for
+ * none set, meaning enter interactive mode. */
+ Tcl_Obj *encoding; /* The encoding of the startup script file. */
+} StartupScript;
+
+static Tcl_ThreadDataKey startupScriptKey;
+
static Tcl_MainLoopProc *mainLoopProc = NULL;
/*
@@ -89,25 +96,28 @@ Tcl_SetStartupScript(
Tcl_Obj *path, /* Filesystem path of startup script file */
const char *encoding) /* Encoding of the data in that file */
{
+ StartupScript *scriptPtr = Tcl_GetThreadData(&startupScriptKey,
+ (int) sizeof(StartupScript));
Tcl_Obj *newEncoding = NULL;
+
if (encoding != NULL) {
newEncoding = Tcl_NewStringObj(encoding, -1);
}
- if (tclStartupScriptPath != NULL) {
- Tcl_DecrRefCount(tclStartupScriptPath);
+ if (scriptPtr->path != NULL) {
+ Tcl_DecrRefCount(scriptPtr->path);
}
- tclStartupScriptPath = path;
- if (tclStartupScriptPath != NULL) {
- Tcl_IncrRefCount(tclStartupScriptPath);
+ scriptPtr->path = path;
+ if (scriptPtr->path != NULL) {
+ Tcl_IncrRefCount(scriptPtr->path);
}
- if (tclStartupScriptEncoding != NULL) {
- Tcl_DecrRefCount(tclStartupScriptEncoding);
+ if (scriptPtr->encoding != NULL) {
+ Tcl_DecrRefCount(scriptPtr->encoding);
}
- tclStartupScriptEncoding = newEncoding;
- if (tclStartupScriptEncoding != NULL) {
- Tcl_IncrRefCount(tclStartupScriptEncoding);
+ scriptPtr->encoding = newEncoding;
+ if (scriptPtr->encoding != NULL) {
+ Tcl_IncrRefCount(scriptPtr->encoding);
}
}
@@ -138,116 +148,17 @@ Tcl_GetStartupScript(
* registered encoding name for the startup
* script */
{
+ StartupScript *scriptPtr = Tcl_GetThreadData(&startupScriptKey,
+ (int) sizeof(StartupScript));
+
if (encodingPtr != NULL) {
- if (tclStartupScriptEncoding == NULL) {
+ if (scriptPtr->encoding == NULL) {
*encodingPtr = NULL;
} else {
- *encodingPtr = Tcl_GetString(tclStartupScriptEncoding);
+ *encodingPtr = Tcl_GetString(scriptPtr->encoding);
}
}
- return tclStartupScriptPath;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclSetStartupScriptPath --
- *
- * Primes the startup script VFS path, used to override the command line
- * processing.
- *
- * Results:
- * None.
- *
- * Side effects:
- * This function initializes the VFS path of the Tcl script to run at
- * startup.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclSetStartupScriptPath(
- Tcl_Obj *path)
-{
- Tcl_SetStartupScript(path, NULL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclGetStartupScriptPath --
- *
- * Gets the startup script VFS path, used to override the command line
- * processing.
- *
- * Results:
- * The startup script VFS path, NULL if none has been set.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tcl_Obj *
-TclGetStartupScriptPath(void)
-{
- return Tcl_GetStartupScript(NULL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclSetStartupScriptFileName --
- *
- * Primes the startup script file name, used to override the command line
- * processing.
- *
- * Results:
- * None.
- *
- * Side effects:
- * This function initializes the file name of the Tcl script to run at
- * startup.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TclSetStartupScriptFileName(
- const char *fileName)
-{
- Tcl_Obj *path = Tcl_NewStringObj(fileName,-1);
- Tcl_SetStartupScript(path, NULL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TclGetStartupScriptFileName --
- *
- * Gets the startup script file name, used to override the command line
- * processing.
- *
- * Results:
- * The startup script file name, NULL if none has been set.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-const char *
-TclGetStartupScriptFileName(void)
-{
- Tcl_Obj *path = Tcl_GetStartupScript(NULL);
-
- if (path == NULL) {
- return NULL;
- }
- return Tcl_GetString(path);
+ return scriptPtr->path;
}
/*----------------------------------------------------------------------