From: <no...@so...> - 2002-12-04 12:01:18
|
Bugs item #616245, was opened at 2002-09-29 19:55 You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=616245&group_id=12997 Category: 74. Application Embedding Group: 8.4.1 Status: Open Resolution: None Priority: 5 Submitted By: Jean-Claude Wippler (jcw) Assigned to: Don Porter (dgp) Summary: tk main eats first arg Initial Comment: When built as tclkit, tkMain.c cannot be made to ignore the first argument. The logic is quite broken, because appinit gets called too late to prevent tclMain.c and tkMain.c from abosrbing a first arg. This required for starpacks - which should *not* treat their first args as scripts. I currently get around this by repairing the damage in my custom appinit hook - it's a bad hack but it works. Unfortunately, on Windows it still fails. The fix is quite easy: introduce the same logic in tkMain.c as is already in tclMain.c. I've attached the patch which does this. The above patch also removes the "-file" arg handling, because that would cause starpacks to still drop a leading "-file" arg - I hope this historical "feature" can be dropped now. It's not a showstopper - just a timebomb for starpack use. -jcw ---------------------------------------------------------------------- >Comment By: Vince Darley (vincentdarley) Date: 2002-12-04 12:01 Message: Logged In: YES user_id=32170 I agree with JCW. Tcl_Main and Tk_Main should behave the same wrt 'Tcl(Get|Set)StartupScriptFileName'. Currently they don't. It seems as if perhaps the '-f(ile)' should stay for the moment, but we can at least at some comments in the code that it is obsolete and will be removed later. Perhaps if we can get a new patch to do the above, it can be applied quickly. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2002-10-10 16:59 Message: Logged In: YES user_id=80530 Thanks for the patch. I think I see. By storing and retrieving the first argument with the Tcl(Get|Set)StartupScriptFileName calls, you give the AppInit routine a chance to change whether the first argument is used as a startup script file name. I guess it also gives you the chance to restore the "argv" global variable as well. It seems the patch leaves the usual usage unchanged, and only adds configuration power to the author of an AppInit routine (even if only via internal calls). The "-file" stuff needs to stick around for now, probably until Tk 9. There's a huge number of existing wish scripts out there with "-f" embedded in them. I think tclkit can work around this by processing argv[] before passing it to Tk_Main. Is there a reason tclkit calls on Tk_Main rather than Tcl_Main ? ---------------------------------------------------------------------- Comment By: Jeffrey Hobbs (hobbs) Date: 2002-10-10 16:31 Message: Logged In: YES user_id=72656 I do not believe that the use of -file, or -f as most people used it, is really fully historical yet. I think that you will find many scripts doing: #!wish -f ... So I vote no on removing that piece. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2002-09-30 01:06 Message: Logged In: YES user_id=80530 Please attach a patch so I can be sure I understand what it is you are requesting. Maybe I just don't get it. I don't see how Tk_Main could ever be a show-stopper, because it is only a convenience routine. There's no essential functionality that it exclusively controls access to, AFAIK. If it does what you want, great. If not, write your own main(). ---------------------------------------------------------------------- Comment By: Jean-Claude Wippler (jcw) Date: 2002-09-29 22:26 Message: Logged In: YES user_id=1983 Tclkit is defintiely a "wish-like" program. It has runtime files at the end, but it talks, looks, and quacks as a wish - as you know. A starpack is a tclkit with more runtime files, an is required to act as an app. This is *not* a recompile, but a post-processing step (sdx -runtime). Re-compiling is not an option, starpacks can be generated cross-platform. Could you please just accept the change - all I did was include the same logic in tkMain.c as what was already present in tclMain.c - surely this is acceptable for the near-term? The "don't eat -file arg" change is less important, but this one really is a show-stopper. I agree that longer term solutions need to address this in a far more fundamental way - but it's hard to see how wish et al could ever have done it right, given that they pre-date the whole concept of starpacks. With that perspective, the hack that tclkit goes through to make starpacks work is really no big deal, IMNSHO. ---------------------------------------------------------------------- Comment By: Don Porter (dgp) Date: 2002-09-29 21:59 Message: Logged In: YES user_id=80530 This is a sign that starpacks should not be calling Tk_Main but should create their own "main" routine. Tk_Main is for the sole purpose of creating wish-like shell programs. Treating the first arg as a script is part of the definition of "wish-like". This may be a fine idea for Tk 9, though. Even better, I think, would be to futher enhance the customize-ability of Tcl_Main so that Tk_Main(Ex) can just disappear into a macro/wrapper for Tcl_Main. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=112997&aid=616245&group_id=12997 |