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 | |
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.
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | generic/tkMain.c | 17 | ||||
-rw-r--r-- | unix/tkAppInit.c | 27 | ||||
-rw-r--r-- | win/winMain.c | 59 |
4 files changed, 93 insertions, 18 deletions
@@ -1,3 +1,11 @@ +1999-12-01 Scott Redman <redman@scriptics.com> + + * 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. + 1999-11-29 Jeff Hobbs <hobbs@scriptics.com> * generic/tkImgGIF.c: added GIF writing that uses miGIF RLE diff --git a/generic/tkMain.c b/generic/tkMain.c index ce33f8a..a7b4bf8 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.5 1999/04/28 18:18:06 redman Exp $ + * RCS: @(#) $Id: tkMain.c,v 1.6 1999/12/02 02:05:34 redman Exp $ */ #include <ctype.h> @@ -137,7 +137,8 @@ Tk_MainEx(argc, argv, appInitProc, interp) * use it as the name of a script file to process. */ - fileName = NULL; + fileName = TclGetStartupScriptFileName(); + if (argc > 1) { length = strlen(argv[1]); if ((length >= 2) && (strncmp(argv[1], "-file", length) == 0)) { @@ -145,12 +146,14 @@ Tk_MainEx(argc, argv, appInitProc, interp) argv++; } } - if ((argc > 1) && (argv[1][0] != '-')) { - fileName = argv[1]; - argc--; - argv++; + if (fileName == NULL) { + if ((argc > 1) && (argv[1][0] != '-')) { + fileName = argv[1]; + argc--; + argv++; + } } - + /* * Make command-line arguments available in the Tcl variables "argc" * and "argv". diff --git a/unix/tkAppInit.c b/unix/tkAppInit.c index cf283fb..4290f2b 100644 --- a/unix/tkAppInit.c +++ b/unix/tkAppInit.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: tkAppInit.c,v 1.4 1999/04/16 01:51:45 stanton Exp $ + * RCS: @(#) $Id: tkAppInit.c,v 1.5 1999/12/02 02:05:39 redman Exp $ */ #include "tk.h" @@ -51,7 +51,30 @@ main(argc, argv) int argc; /* Number of command-line arguments. */ char **argv; /* Values of command-line arguments. */ { - Tk_Main(argc, argv, Tcl_AppInit); + /* + * 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)); + TK_LOCAL_MAIN_HOOK(&argc, &argv); +#endif + + Tk_Main(argc, argv, TK_LOCAL_APPINIT); return 0; /* Needed only to prevent compiler warning. */ } 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; } |