Index: src/main.c ================================================================== --- src/main.c +++ src/main.c @@ -411,16 +411,10 @@ const char *zCmdName = "unknown"; int idx; int rc; int i; -#ifdef FOSSIL_ENABLE_TCL - g.tcl.argc = argc; - g.tcl.argv = argv; - g.tcl.interp = 0; -#endif - sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); memset(&g, 0, sizeof(g)); g.now = time(0); g.argc = argc; g.argv = argv; @@ -436,22 +430,25 @@ g.json.outOpt = cson_output_opt_empty; g.json.outOpt.addNewline = 1; g.json.outOpt.indentation = 1 /* in CGI/server mode this can be configured */; #endif /* FOSSIL_ENABLE_JSON */ expand_args_option(); - argc = g.argc; - argv = g.argv; - for(i=0; iinterp ){ return TH_OK; } - if ( tclContext->argc>0 && tclContext->argv ) { - Tcl_FindExecutable(tclContext->argv[0]); - } + Tcl_FindExecutable(tclContext->argv[0]); tclInterp = tclContext->interp = Tcl_CreateInterp(); if( !tclInterp || Tcl_InterpDeleted(tclInterp) ){ Th_ErrorMessage(interp, "Could not create Tcl interpreter", (const char *)"", 0); return TH_ERROR; @@ -405,10 +403,20 @@ "Tcl initialization error:", Tcl_GetStringResult(tclInterp), -1); Tcl_DeleteInterp(tclInterp); tclContext->interp = tclInterp = 0; return TH_ERROR; } + if (tclContext->argc > 0) { + int argc = tclContext->argc - 1; + char **argv = tclContext->argv + 1; + Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL); + while (argc--) { + Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(*argv++, -1)); + } + Tcl_SetVar2Ex(tclContext->interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY); + } + /* Add the TH1 integration commands to Tcl. */ Tcl_CallWhenDeleted(tclInterp, Th1DeleteProc, interp); Tcl_CreateObjCommand(tclInterp, "th1Eval", Th1EvalObjCmd, interp, NULL); Tcl_CreateObjCommand(tclInterp, "th1Expr", Th1ExprObjCmd, interp, NULL); return TH_OK;