summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-10 09:23:39 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-01-10 09:23:39 (GMT)
commit2930daf68ce7f2d1c8d17c5e4c7084d77d21aa1c (patch)
treea0c98594c805de0c60f6583c90ea930bc0cefd51 /generic
parent0481e3ca74a06381151d36ed72e32d8c12c7c29d (diff)
parent8f2f7117fc58a586d63160ce0df15bc7112fa169 (diff)
downloadtcl-2930daf68ce7f2d1c8d17c5e4c7084d77d21aa1c.zip
tcl-2930daf68ce7f2d1c8d17c5e4c7084d77d21aa1c.tar.gz
tcl-2930daf68ce7f2d1c8d17c5e4c7084d77d21aa1c.tar.bz2
Implement TCL_INIT_CREATE_UTF8/TCL_INIT_CREATE_UNICODE
Diffstat (limited to 'generic')
-rw-r--r--generic/tcl.h7
-rw-r--r--generic/tclEncoding.c26
2 files changed, 22 insertions, 11 deletions
diff --git a/generic/tcl.h b/generic/tcl.h
index 8a7911b..efe950e 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -2412,7 +2412,9 @@ const char * TclTomMathInitializeStubs(Tcl_Interp *interp,
/* Tcl_InitSubsystems, see TIP ??? */
#define TCL_INIT_PANIC (1) /* Set Panic proc */
-#define TCL_INIT_CREATE (4) /* Call Tcl_CreateInterp(), and set argc/argv */
+#define TCL_INIT_CREATE (48) /* Call Tcl_CreateInterp(), and set argc/argv */
+#define TCL_INIT_CREATE_UNICODE (16) /* The same, but argv is in unicode */
+#define TCL_INIT_CREATE_UTF8 (32) /* The same, but argv is in utf-8 */
EXTERN Tcl_Interp *Tcl_InitSubsystems(int flags, ...);
@@ -2422,8 +2424,7 @@ EXTERN Tcl_Interp *Tcl_InitSubsystems(int flags, ...);
*/
#define Tcl_Main(argc, argv, proc) Tcl_MainEx(argc, argv, proc, \
- Tcl_InitSubsystems(TCL_INIT_CREATE, argc, argv))
-// (Tcl_FindExecutable(argv[0]), (Tcl_CreateInterp)()))
+ (Tcl_FindExecutable(argv[0]), (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 9a64f10..257089e 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1446,7 +1446,7 @@ Tcl_InitSubsystems(int flags, ...)
va_list argList;
int argc = 0;
- char **argv = NULL;
+ void **argv = NULL;
va_start(argList, flags);
if (flags & TCL_INIT_PANIC) {
@@ -1454,7 +1454,7 @@ Tcl_InitSubsystems(int flags, ...)
}
if (flags & TCL_INIT_CREATE) {
argc = va_arg(argList, int);
- argv = va_arg(argList, char **);
+ argv = va_arg(argList, void **);
}
va_end (argList);
@@ -1463,18 +1463,28 @@ Tcl_InitSubsystems(int flags, ...)
TclpFindExecutable(argv ? argv[0] : NULL);
if (flags & TCL_INIT_CREATE) {
Tcl_Interp *interp = Tcl_CreateInterp();
- if (argc > 0) {
+ if (--argc >= 0) {
Tcl_Obj *argvPtr;
- argc--;
- argv++;
Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(argc, NULL);
- while (argc--) {
+ if ((flags & TCL_INIT_CREATE) == TCL_INIT_CREATE_UTF8) {
+ while (argc--) {
+ Tcl_ListObjAppendElement(NULL, argvPtr,
+ Tcl_NewStringObj(*++argv, -1));
+ }
+ } else if ((flags & TCL_INIT_CREATE) == TCL_INIT_CREATE_UNICODE) {
+ while (argc--) {
+ Tcl_ListObjAppendElement(NULL, argvPtr,
+ Tcl_NewUnicodeObj(*++argv, -1));
+ }
+ } else {
Tcl_DString ds;
- Tcl_ExternalToUtfDString(NULL, *argv++, -1, &ds);
- Tcl_ListObjAppendElement(NULL, argvPtr, TclDStringToObj(&ds));
+ while (argc--) {
+ Tcl_ExternalToUtfDString(NULL, *++argv, -1, &ds);
+ Tcl_ListObjAppendElement(NULL, argvPtr, TclDStringToObj(&ds));
+ }
}
Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
}