From 8304318737dab8f9fff952f3c99469f815253c44 Mon Sep 17 00:00:00 2001 From: bagnonm Date: Tue, 16 Apr 2002 11:41:53 +0000 Subject: new feature request, 539309 make dependence on msgcat "soft" msgcat procedures as used in tk defined in case the package is not available. --- library/tk.tcl | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/library/tk.tcl b/library/tk.tcl index e7379c1..364d084 100644 --- a/library/tk.tcl +++ b/library/tk.tcl @@ -3,7 +3,7 @@ # Initialization script normally executed in the interpreter for each # Tk-based application. Arranges class bindings for widgets. # -# RCS: @(#) $Id: tk.tcl,v 1.35 2002/02/22 14:07:01 dkf Exp $ +# RCS: @(#) $Id: tk.tcl,v 1.36 2002/04/16 11:41:53 bagnonm Exp $ # # Copyright (c) 1992-1994 The Regents of the University of California. # Copyright (c) 1994-1996 Sun Microsystems, Inc. @@ -17,8 +17,35 @@ package require -exact Tk 8.4 package require -exact Tcl 8.4 if { ![interp issafe] } { - package require msgcat - ::msgcat::mcload [file join $::tk_library msgs] + if {[catch {package require msgcat}]} { + # msgcat not found. A minimal msgcat is defined + # here, with fail-safe versions of the msgcat::mc and + # msgcat::mcmax procedures, which happen to be the msgcat + # services used by tk widgets. + # See the msgcat package for details about the simulated + # procedures. + namespace eval msgcat { + namespace export mc mcmax + + proc mc {src args} { + return [eval [list format $src $args]] + } + + proc mcmax {args} { + set max 0 + foreach string $args { + set len [string length [msgcat::mc $string]] + if {$len>$max} { + set max $len + } + } + return $max + } + + } + } else { + ::msgcat::mcload [file join $::tk_library msgs] + } } # Add Tk's directory to the end of the auto-load search path, if it -- cgit v0.12