summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2005-09-30 19:31:16 (GMT)
committerdgp <dgp@users.sourceforge.net>2005-09-30 19:31:16 (GMT)
commit8a7bf54a77fffd5f4aa0b6617c743d770f092b80 (patch)
treeb778cb3f0346c5045f3cae7faa37f1b74c5bfe56
parent9746ade49f1bf6a262e7913e38ed2172d14cb3d8 (diff)
downloadtcl-8a7bf54a77fffd5f4aa0b6617c743d770f092b80.zip
tcl-8a7bf54a77fffd5f4aa0b6617c743d770f092b80.tar.gz
tcl-8a7bf54a77fffd5f4aa0b6617c743d770f092b80.tar.bz2
* generic/tclMain.c: Separate encoding conversion of command line
arguments from list formatting. [Bug 1306162].
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclMain.c51
2 files changed, 28 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 5d6fe50..6daa1e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-09-30 Don Porter <dgp@users.sourceforge.net>
+
+ * generic/tclMain.c: Separate encoding conversion of command line
+ arguments from list formatting. [Bug 1306162].
+
2005-09-29 Jeff Hobbs <jeffh@ActiveState.com>
* doc/mathfunc.n: implementation for TIP #255, expr min/max
diff --git a/generic/tclMain.c b/generic/tclMain.c
index 75fa70b..f755a8d 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.32 2005/09/15 16:40:02 dgp Exp $
+ * RCS: @(#) $Id: tclMain.c,v 1.33 2005/09/30 19:31:16 dgp Exp $
*/
#include "tclInt.h"
@@ -339,17 +339,13 @@ Tcl_Main(argc, argv, appInitProc)
* procedure to call after most initialization
* but before starting to execute commands. */
{
- Tcl_Obj *path;
- Tcl_Obj *resultPtr;
- Tcl_Obj *commandPtr = NULL;
+ Tcl_Obj *path, *resultPtr, *argvPtr, *commandPtr = NULL;
CONST char *encodingName = NULL;
- char *args;
PromptType prompt = PROMPT_START;
- int code, length, tty;
- int exitCode = 0;
+ int code, length, tty, exitCode = 0;
Tcl_Channel inChannel, outChannel, errChannel;
Tcl_Interp *interp;
- Tcl_DString argString;
+ Tcl_DString appName;
Tcl_FindExecutable(argv[0]);
@@ -383,31 +379,31 @@ Tcl_Main(argc, argv, appInitProc)
}
}
- /*
- * The CONST casting is safe, and better we do it here than force all
- * callers of Tcl_Main to do it. (Those callers are likely in a main()
- * that can't easily change its signature.)
- */
-
- args = Tcl_Merge(argc-1, (CONST char **)argv+1);
- Tcl_ExternalToUtfDString(NULL, args, -1, &argString);
- Tcl_SetVar(interp, "argv", Tcl_DStringValue(&argString), TCL_GLOBAL_ONLY);
- Tcl_DStringFree(&argString);
- ckfree(args);
-
path = Tcl_GetStartupScript(&encodingName);
if (path == NULL) {
- Tcl_ExternalToUtfDString(NULL, argv[0], -1, &argString);
+ Tcl_ExternalToUtfDString(NULL, argv[0], -1, &appName);
} else {
CONST char *pathName = Tcl_GetStringFromObj(path, &length);
- Tcl_ExternalToUtfDString(NULL, pathName, length, &argString);
- path = Tcl_NewStringObj(Tcl_DStringValue(&argString), -1);
+ Tcl_ExternalToUtfDString(NULL, pathName, length, &appName);
+ path = Tcl_NewStringObj(Tcl_DStringValue(&appName), -1);
Tcl_SetStartupScript(path, encodingName);
}
-
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1),
- TCL_GLOBAL_ONLY);
- Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&argString), TCL_GLOBAL_ONLY);
+ Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&appName), TCL_GLOBAL_ONLY);
+ Tcl_DStringFree(&appName);
+ argc--;
+ argv++;
+
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+
+ argvPtr = Tcl_NewListObj(0, NULL);
+ while (argc--) {
+ Tcl_DString ds;
+ Tcl_ExternalToUtfDString(NULL, *argv++, -1, &ds);
+ Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(
+ Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)));
+ Tcl_DStringFree(&ds);
+ }
+ Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
/*
* Set the "tcl_interactive" variable.
@@ -466,7 +462,6 @@ Tcl_Main(argc, argv, appInitProc)
}
goto done;
}
- Tcl_DStringFree(&argString);
/*
* We're running interactively. Source a user-specific startup file if the