git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] gitk: Initialize msgcat before first use

From
BHBernt Hansen <bernt@norang.ca>
Date
Nov 1, 2009, 13:09 UTC
Message-ID
<874opel7de.fsf@gollum.intra.norang.ca>
In-Reply-To
<87d443xn5u.fsf@users.sourceforge.net>
Pat Thoyts <patthoyts@users.sourceforge.net> writes:
Show 25 quoted lines
> Bernt Hansen <bernt@norang.ca> writes:
>
>>The error text generated when your version of Tcl is too old is
>>translated with msgcat (mc) before msgcat is initialized.  This
>>causes Tcl to abort with:
>>
>>    Error in startup script: invalid command name "mc"
>>
>>We now initialize msgcat first before we check the Tcl version.  Msgcat
>>is available since Tcl 8.1.
>>
>
> This doesn't quite work. [file normalize] was introduced with Tcl 8.4
> and when I test this by starting it using Tcl 8.3 I get an error:
>  "bad option "normalize": must be atime, attributes, channels..."
> from line 11014. It is probably sufficient to just drop the [file
> normalize] here. On Windows $argv0 is fully qualified and 
> [file dirname] works ok on it. By removing the [file normalize] I get
> the expected error dialog when testing with 8.3.
> However, on Windows we actually get a better looking result by not
> catching the [package require Tcl 8.4] and just letting Tk bring up a
> standard message box with the version conflict error message.
>
> Well, actually if show_error just used tk_messageBox it would look
> better on Windows.

You're right. Thanks for catching this. When I tested this code I bumped the version number temporarily to 8.5 instead of downgrading TK to 8.3.

The problem I was trying to fix was show_error using mc internally before it was initialized. Maybe it would be better to give show_error an optional parameter that controls calling mc - so that the call for the version check can just bypass the mc translation of the text and OK buttons. With this approach the code I moved around can just stay where it is and all of the existing calls to show_error will use the default parameter setting which invokes mc.

Would that be a better approach?
-Bernt
Previous: Pat ThoytsNext: Bernt Hansen
Message 4 of 8 in “gitk: Fix error display when Tcl is too old”
  1. 0/2 gitk: Fix error display when Tcl is too oldBernt Hansen, Oct 24, 2009
  2. 1/2 gitk: Initialize msgcat before first useBernt Hansen, Oct 24, 2009
  3. Pat ThoytsOct 31, 2009
  4. Bernt HansenNov 1, 2009
  5. Skip translation of wrong Tcl version textBernt Hansen, Nov 2, 2009
  6. Paul MackerrasNov 3, 2009
  7. 2/2 gitk: Provide a default mc function if msgcat is not availableBernt Hansen, Oct 24, 2009
  8. Junio C HamanoOct 24, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.