summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-18 08:13:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-06-18 08:13:22 (GMT)
commit0db50478bc91bb9fcd4e675581d3f79ad04b9e2c (patch)
tree8a729d803cb5d4481499338642a698741b964b38 /generic
parent76df95e6e49c926b2b3f71f8b740221e897a7643 (diff)
parent3ff5e13b09cf7aea196f837251be4d3b82a17c0d (diff)
downloadtcl-0db50478bc91bb9fcd4e675581d3f79ad04b9e2c.zip
tcl-0db50478bc91bb9fcd4e675581d3f79ad04b9e2c.tar.gz
tcl-0db50478bc91bb9fcd4e675581d3f79ad04b9e2c.tar.bz2
Simplify TIP #414 implementation by using the function TclInitStubTable() in stead of re-use Tcl_InitStubs().
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h12
-rw-r--r--generic/tclEncoding.c27
-rw-r--r--generic/tclInt.h2
-rw-r--r--generic/tclMain.c3
4 files changed, 36 insertions, 8 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index d47e931..739966c 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2397,6 +2397,8 @@ const char * Tcl_InitStubs(Tcl_Interp *interp, const char *version,
int exact);
const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
const char *version, int epoch, int revision);
+const char * TclInitStubTable(const char *version);
+
/*
* When not using stubs, make it a macro.
@@ -2411,13 +2413,21 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
* TODO - tommath stubs export goes here!
*/
+/* Tcl_InitSubsystems, see TIP #414 */
+
+EXTERN const char *Tcl_InitSubsystems(Tcl_PanicProc *panicProc);
+#ifdef USE_TCL_STUBS
+#define Tcl_InitSubsystems(panicProc) \
+ TclInitStubTable((Tcl_InitSubsystems)(panicProc))
+#endif
+
/*
* Public functions that are not accessible via the stubs table.
* Tcl_GetMemoryInfo is needed for AOLserver. [Bug 1868171]
*/
#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
- (Tcl_FindExecutable(argv[0]), (Tcl_CreateInterp)()))
+ (Tcl_InitSubsystems(NULL), Tcl_CreateInterp()))
EXTERN void Tcl_MainEx(int argc, char **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
EXTERN const char * Tcl_PkgInitStubsCheck(Tcl_Interp *interp,
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 2cc55d6..b94e355 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1411,21 +1411,40 @@ Tcl_UtfToExternal(
/*
*---------------------------------------------------------------------------
*
- * Tcl_FindExecutable --
+ * Tcl_InitSubsystems/Tcl_FindExecutable --
*
- * This function computes the absolute path name of the current
- * application, given its argv[0] value.
+ * This function initializes everything needed for the Tcl library
+ * to be able to operate.
*
* Results:
* None.
*
* Side effects:
* The absolute pathname for the application is computed and stored to be
- * returned later be [info nameofexecutable].
+ * returned later by [info nameofexecutable]. The system encoding is
+ * determined and stored to be returned later by [encoding system]
*
*---------------------------------------------------------------------------
*/
+MODULE_SCOPE const TclStubs tclStubs;
+
+/* Structure returned by Tcl_InitSubsystems, which can be interpreted
+ * as the Tcl version, but also can be used to initialize the stub table. */
+static const TclStubInfoType stubInfo = {
+ TCL_PATCH_LEVEL, (ClientData) &tclStubs
+};
+
#undef Tcl_FindExecutable
+const char *
+Tcl_InitSubsystems(Tcl_PanicProc *panicProc)
+{
+ if (panicProc) {
+ Tcl_SetPanicProc(panicProc);
+ }
+ TclInitSubsystems();
+ return stubInfo.version;
+}
+
void
Tcl_FindExecutable(
const char *argv0) /* The value of the application's argv[0]
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 3432b37..346fa96 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3840,8 +3840,6 @@ typedef struct {
ClientData data;
} TclStubInfoType;
-MODULE_SCOPE const char *TclInitStubTable(const char *version);
-
/*
* Functions defined in generic/tclVar.c and currenttly exported only for use
* by the bytecode compiler and engine. Some of these could later be placed in
diff --git a/generic/tclMain.c b/generic/tclMain.c
index f445383..7a31d43 100644
--- a/generic/tclMain.c
+++ b/generic/tclMain.c
@@ -313,6 +313,8 @@ Tcl_MainEx(
Tcl_Channel chan;
InteractiveState is;
+ TclpSetInitialEncodings();
+ TclpFindExecutable((void *)argv[0]);
Tcl_InitMemory(interp);
is.interp = interp;
@@ -640,7 +642,6 @@ Tcl_Main(
* function to call after most initialization
* but before starting to execute commands. */
{
- Tcl_FindExecutable(argv[0]);
Tcl_MainEx(argc, argv, appInitProc, Tcl_CreateInterp());
}
#endif /* TCL_MAJOR_VERSION == 8 && !UNICODE */