diff options
author | redman <redman@noemail.net> | 1999-12-02 02:03:15 (GMT) |
---|---|---|
committer | redman <redman@noemail.net> | 1999-12-02 02:03:15 (GMT) |
commit | a2a828968846c2d0bd54f397b7f82e3e1543cac8 (patch) | |
tree | 16cb4502c47ea8cd6f0e507e1e7e9ef7f76801a6 /win/tclAppInit.c | |
parent | 5ad2ea7cdd56cc81a7427c562347b014e6eb3faa (diff) | |
download | tcl-a2a828968846c2d0bd54f397b7f82e3e1543cac8.zip tcl-a2a828968846c2d0bd54f397b7f82e3e1543cac8.tar.gz tcl-a2a828968846c2d0bd54f397b7f82e3e1543cac8.tar.bz2 |
* generic/tcl.decls :
* generic/tclMain.c :
* unix/tclAppInit.c:
* win/tclAppInit.c: Added two new internal functions,
TclSetStartupScriptFileName() and TclGetStartupScriptFileName()
and added hooks into the main() code for supporting TclPro and
other "big" shells more easily without requiring a copy of the
main() code.
* generic/tclEncoding.c:
* generic/tclEvent.c: Moved encoding-related startup code from
tclEvent.c into the more appropriate tclEncoding.c.
FossilOrigin-Name: cafaa4d04661ff95bf15eaa7e7562cef869a8258
Diffstat (limited to 'win/tclAppInit.c')
-rw-r--r-- | win/tclAppInit.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/win/tclAppInit.c b/win/tclAppInit.c index d157656..b8f3e78 100644 --- a/win/tclAppInit.c +++ b/win/tclAppInit.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclAppInit.c,v 1.5 1999/04/16 00:48:07 stanton Exp $ + * RCS: @(#) $Id: tclAppInit.c,v 1.6 1999/12/02 02:03:37 redman Exp $ */ #include "tcl.h" @@ -54,6 +54,30 @@ main(argc, argv) char **argv; /* Values of command-line arguments. */ { /* + * The following #if block allows you to change the AppInit + * function by using a #define of TCL_LOCAL_APPINIT instead + * of rewriting this entire file. The #if checks for that + * #define and uses Tcl_AppInit if it doesn't exist. + */ + +#ifndef TCL_LOCAL_APPINIT +#define TCL_LOCAL_APPINIT Tcl_AppInit +#endif + extern int TCL_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); + + /* + * The following #if block allows you to change how Tcl finds the startup + * script, prime the library or encoding paths, fiddle with the argv, + * etc., without needing to rewrite Tcl_Main() + */ + +#ifdef TCL_LOCAL_MAIN_HOOK + extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); +#endif + + char buffer[MAX_PATH +1]; + char *p; + /* * Set up the default locale to be standard "C" locale so parsing * is performed correctly. */ @@ -61,7 +85,25 @@ main(argc, argv) setlocale(LC_ALL, "C"); setargv(&argc, &argv); - Tcl_Main(argc, argv, Tcl_AppInit); + /* + * Replace argv[0] with full pathname of executable, and forward + * slashes substituted for backslashes. + */ + + GetModuleFileName(NULL, buffer, sizeof(buffer)); + argv[0] = buffer; + for (p = buffer; *p != '\0'; p++) { + if (*p == '\\') { + *p = '/'; + } + } + +#ifdef TCL_LOCAL_MAIN_HOOK + TCL_LOCAL_MAIN_HOOK(&argc, &argv); +#endif + + Tcl_Main(argc, argv, TCL_LOCAL_APPINIT); + return 0; /* Needed only to prevent compiler warning. */ } |