summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/InitSubSyst.38
-rw-r--r--generic/tcl.h1
-rw-r--r--generic/tclEncoding.c7
3 files changed, 14 insertions, 2 deletions
diff --git a/doc/InitSubSyst.3 b/doc/InitSubSyst.3
index 0125912..4a3dc64 100644
--- a/doc/InitSubSyst.3
+++ b/doc/InitSubSyst.3
@@ -19,7 +19,8 @@ Tcl_Interp *
.AS int flags
.AP int flags in
Any combination of flags which might modify the initialization sequence.
-At this moment, only 0 and \fBTCL_INIT_PANIC\fR are supported.
+At this moment, only 0, \fBTCL_INIT_PANIC\fR and \fBTCL_INIT_STUFF\fR
+(or a combination) are supported.
The value 0 can be used if Tcl is used as utility library only.
.BE
@@ -74,6 +75,11 @@ could call \fBTcl_SetPanicProc\fR immediately after \fBTcl_InitSubsystems\fR,
but then panics which could be produced by the initialization
itself still use the default panic procedure.
.PP
+If you supply the flag \fBTCL_INIT_STUFF\fR to \fBTcl_InitSubsystems\fR,
+the function expects two additional arguments: ClientData and a
+custom proc with has ClientData as its only argument. The given
+function will be executed just before the encodings are initialized.
+.PP
The interpreter returned by Tcl_InitSubsystems(0) cannot be passed to
any other function than Tcl_InitStubs(). Tcl functions with an "interp"
argument can only be called if the function supports passing NULL.
diff --git a/generic/tcl.h b/generic/tcl.h
index 4049c8a..9325bf2 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2412,6 +2412,7 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
/* Tcl_InitSubsystems, see TIP #414 */
#define TCL_INIT_PANIC (1) /* Set Panic proc */
+#define TCL_INIT_STUFF (2) /* Do any stuff before initializing the encoding */
EXTERN Tcl_Interp *Tcl_InitSubsystems(int flags, ...);
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 0ffc481..753222f 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1451,9 +1451,14 @@ Tcl_InitSubsystems(int flags, ...)
if (flags & TCL_INIT_PANIC) {
Tcl_SetPanicProc(va_arg(argList, Tcl_PanicProc *));
}
+ TclInitSubsystems();
+ if (flags & TCL_INIT_STUFF) {
+ ClientData clientData = va_arg(argList, ClientData);
+ void (*fn)() = va_arg(argList, void (*)(ClientData));
+ fn(clientData);
+ }
va_end(argList);
- TclInitSubsystems();
TclpSetInitialEncodings();
TclpFindExecutable(NULL);
return (Tcl_Interp *) &dummyInterp;