diff options
author | dgp <dgp@users.sourceforge.net> | 2005-10-18 15:16:01 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2005-10-18 15:16:01 (GMT) |
commit | c1607eed2c6df4f8800e5bc981ca4c441324e085 (patch) | |
tree | 79507968cd8b9b1b10ae0f2ab2440003bcaa99cc /generic/tkMain.c | |
parent | d1c304bb096bd57d496fca0478a1a3383fb63fea (diff) | |
download | tk-c1607eed2c6df4f8800e5bc981ca4c441324e085.zip tk-c1607eed2c6df4f8800e5bc981ca4c441324e085.tar.gz tk-c1607eed2c6df4f8800e5bc981ca4c441324e085.tar.bz2 |
* generic/tkMain.c: Rewrote code that sets the ::argv value
to be sure conversion from the system encoding is complete before
any processing sensitive to list-special characters is done.
[Bug 1328926].
Diffstat (limited to 'generic/tkMain.c')
-rw-r--r-- | generic/tkMain.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/generic/tkMain.c b/generic/tkMain.c index 25f0d9d..b6377f6 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -13,7 +13,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMain.c,v 1.15.2.1 2004/11/11 01:26:42 das Exp $ + * RCS: @(#) $Id: tkMain.c,v 1.15.2.2 2005/10/18 15:16:01 dgp Exp $ */ #include <ctype.h> @@ -102,12 +102,11 @@ Tk_MainEx(argc, argv, appInitProc, interp) * to execute commands. */ Tcl_Interp *interp; { - char *args; - char buf[TCL_INTEGER_SPACE]; + Tcl_Obj *argvPtr; int code; size_t length; Tcl_Channel inChannel, outChannel; - Tcl_DString argString; + Tcl_DString appName; ThreadSpecificData *tsdPtr; #ifdef __WIN32__ HANDLE handle; @@ -169,21 +168,28 @@ Tk_MainEx(argc, argv, appInitProc, interp) * and "argv". */ - 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); - sprintf(buf, "%d", argc-1); - if (TclGetStartupScriptFileName() == NULL) { - Tcl_ExternalToUtfDString(NULL, argv[0], -1, &argString); + Tcl_ExternalToUtfDString(NULL, argv[0], -1, &appName); } else { TclSetStartupScriptFileName(Tcl_ExternalToUtfDString(NULL, - TclGetStartupScriptFileName(), -1, &argString)); + TclGetStartupScriptFileName(), -1, &appName)); + } + 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_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY); - Tcl_SetVar(interp, "argv0", Tcl_DStringValue(&argString), TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY); /* * Set the "tcl_interactive" variable. @@ -274,7 +280,6 @@ Tk_MainEx(argc, argv, appInitProc, interp) Prompt(interp, 0); } } - Tcl_DStringFree(&argString); outChannel = Tcl_GetStdChannel(TCL_STDOUT); if (outChannel) { |