summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2013-03-29 13:17:18 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2013-03-29 13:17:18 (GMT)
commit4cb90fcbec98db39323e1b56e944b85bf64c1801 (patch)
treec17357545d58182bed179357bb7b9c5cc60a34ac
parentc310833021527bb78a862501a5be64ab86c00ca3 (diff)
downloadtcl-initsubsystems2.zip
tcl-initsubsystems2.tar.gz
tcl-initsubsystems2.tar.bz2
revert previous 2 commits: Setting argv0 as well is not a good idea. Needs to be worked out further, but can always be done outside of Tcl_InitSubsystems()initsubsystems2
-rw-r--r--doc/InitSubSyst.39
-rw-r--r--generic/tclEncoding.c53
2 files changed, 24 insertions, 38 deletions
diff --git a/doc/InitSubSyst.3 b/doc/InitSubSyst.3
index 7bd91c2..3c3fbdf 100644
--- a/doc/InitSubSyst.3
+++ b/doc/InitSubSyst.3
@@ -37,11 +37,8 @@ If you supply one of the flags \fBTCL_INIT_CREATE\fR, \fBTCL_INIT_CREATE_UTF8\fR
gets two additional parameters, argc and argv, immediatly following
the flags parameter. Then a Tcl interpreter will be created. If
argc > 0 then the variables \fBargc\fR and \fBargv\fR will be set
-in this interpreter. If argv is specified, irrespective of the value
-of argc, the variable \fBargv0\fR will be set in the interpreter, and
-this value will be used to determine the value returned by
-"info executable". The 3 flag variants assume a different encoding for
-the arguments, except for \fIargv0\fR which is always assumed to
+in this interpreter. The 3 variants assume a different encoding for
+the arguments, except for \fIargv[0]\fR which is always assumed to
be in the system encoding.
.PP
If you supply the flag \fBTCL_INIT_CUSTOM\fR to \fBTcl_InitSubsystems\fR,
@@ -63,7 +60,7 @@ The reason for \fBargv[0]\fR always using the system encoding is that this way,
argv[0] can be derived directly from the main() (or mainw, on Windows)
arguments without any processing. \fBTCL_INIT_CREATE_UNICODE\fR is really only
useful on Windows. But on Windows, the argv[0] parameter is not used for
-determining the value of "info executable" anyway. Modern UNIX system already
+determining the value of [info executable] anyway. Modern UNIX system already
have UTF-8 as system encoding, so \fBTCL_INIT_CREATE_UTF8\fR would have the same
effect as \fBTCL_INIT_CREATE\fR, only slightly faster. Other parameters can be
preprocessed at will by the application, and if the application uses unicode
diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c
index 9d00670..a42e883 100644
--- a/generic/tclEncoding.c
+++ b/generic/tclEncoding.c
@@ -1433,7 +1433,6 @@ Tcl_InitSubsystems(int flags, ...)
va_list argList;
int argc = 0;
void **argv = NULL;
- const char *argv0 = NULL;
Tcl_Interp *interp = NULL;
TclInitSubsystems();
@@ -1441,9 +1440,6 @@ Tcl_InitSubsystems(int flags, ...)
if (flags & TCL_INIT_CREATE) {
argc = va_arg(argList, int);
argv = va_arg(argList, void **);
- if (argv) {
- argv0 = argv[0];
- }
interp = Tcl_CreateInterp();
}
if (flags & TCL_INIT_CUSTOM) {
@@ -1455,38 +1451,31 @@ Tcl_InitSubsystems(int flags, ...)
va_end(argList);
TclpSetInitialEncodings();
- TclpFindExecutable(argv0);
- if (flags&TCL_INIT_CREATE) {
+ TclpFindExecutable(argv ? argv[0] : NULL);
+ if ((flags&TCL_INIT_CREATE) && (--argc >= 0)) {
Tcl_Obj *argvPtr;
- Tcl_DString ds;
- if (argv0) {
- Tcl_ExternalToUtfDString(NULL, argv0, -1, &ds);
- Tcl_SetVar2Ex(interp, "argv0", NULL, TclDStringToObj(&ds),
- TCL_GLOBAL_ONLY);
- }
- if(--argc >= 0) {
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc),
- TCL_GLOBAL_ONLY);
- argvPtr = Tcl_NewListObj(argc, NULL);
- 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 {
- while (argc--) {
- Tcl_ExternalToUtfDString(NULL, *++argv, -1, &ds);
- Tcl_ListObjAppendElement(NULL, argvPtr, TclDStringToObj(&ds));
- }
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+ argvPtr = Tcl_NewListObj(argc, NULL);
+ 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;
+
+ while (argc--) {
+ Tcl_ExternalToUtfDString(NULL, *++argv, -1, &ds);
+ Tcl_ListObjAppendElement(NULL, argvPtr, TclDStringToObj(&ds));
}
- Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
}
+ Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
}
return interp;
}