diff options
author | redman <redman> | 1999-12-02 02:05:31 (GMT) |
---|---|---|
committer | redman <redman> | 1999-12-02 02:05:31 (GMT) |
commit | 47db144ca5053ea42c75249d1269230a1f3eb8fa (patch) | |
tree | ed0a121bdb6db0a3a36b7cd89a95be74a4409332 /win/winMain.c | |
parent | 0a8a3449f94769a8d0934f7cfefa9145a4a74df1 (diff) | |
download | tk-47db144ca5053ea42c75249d1269230a1f3eb8fa.zip tk-47db144ca5053ea42c75249d1269230a1f3eb8fa.tar.gz tk-47db144ca5053ea42c75249d1269230a1f3eb8fa.tar.bz2 |
* generic/tkMain.c :
* unix/tkAppInit.c:
* win/winMain.c: Added added hooks into the main() code for
supporting TclPro and other "big" shells more easily without
requiring a copy of the main() code.
Diffstat (limited to 'win/winMain.c')
-rw-r--r-- | win/winMain.c | 59 |
1 files changed, 50 insertions, 9 deletions
diff --git a/win/winMain.c b/win/winMain.c index cd80bbe..d17c4ce 100644 --- a/win/winMain.c +++ b/win/winMain.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: winMain.c,v 1.8 1999/11/10 02:56:42 hobbs Exp $ + * RCS: @(#) $Id: winMain.c,v 1.9 1999/12/02 02:05:46 redman Exp $ */ #include <tk.h> @@ -72,16 +72,32 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow) { char **argv; int argc; - - Tcl_SetPanicProc(WishPanic); - + char buffer[MAX_PATH+1]; + char *p; + /* - * Set up the default locale to be standard "C" locale so parsing - * is performed correctly. + * 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 TK_LOCAL_APPINIT +#define TK_LOCAL_APPINIT Tcl_AppInit +#endif + extern int TK_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 Tk_Main() + */ + +#ifdef TK_LOCAL_MAIN_HOOK + extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); +#endif - setlocale(LC_ALL, "C"); - setargv(&argc, &argv); + Tcl_SetPanicProc(WishPanic); /* * Increase the application queue size from default value of 8. @@ -101,7 +117,32 @@ WinMain(hInstance, hPrevInstance, lpszCmdLine, nCmdShow) consoleRequired = TRUE; - Tk_Main(argc, argv, Tcl_AppInit); + /* + * Set up the default locale to be standard "C" locale so parsing + * is performed correctly. + */ + + setlocale(LC_ALL, "C"); + setargv(&argc, &argv); + + /* + * 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 TK_LOCAL_MAIN_HOOK + TK_LOCAL_MAIN_HOOK(&argc, &argv); +#endif + + Tk_Main(argc, argv, TK_LOCAL_APPINIT); return 1; } |