diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-21 17:03:54 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-06-21 17:03:54 (GMT) |
commit | 6cabd70c0dad93b763c05c2893f02a868e7dad82 (patch) | |
tree | 376000ac77efa31b5ba87715f2835f15c46ffd53 /library/msgcat | |
parent | 5bbb147862ea23bdd98ad9dbcb4c539da07a9bbc (diff) | |
download | tcl-6cabd70c0dad93b763c05c2893f02a868e7dad82.zip tcl-6cabd70c0dad93b763c05c2893f02a868e7dad82.tar.gz tcl-6cabd70c0dad93b763c05c2893f02a868e7dad82.tar.bz2 |
Rewrite msgcat::mcutil::getpreferences, not depending on 'string last' returning -1 any more
Diffstat (limited to 'library/msgcat')
-rw-r--r-- | library/msgcat/msgcat.tcl | 22 | ||||
-rw-r--r-- | library/msgcat/pkgIndex.tcl | 2 |
2 files changed, 13 insertions, 11 deletions
diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 9f7d54a..e55f93e 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -15,7 +15,7 @@ package require Tcl 8.7- # When the version number changes, be sure to update the pkgIndex.tcl file, # and the installation directory in the Makefiles. -package provide msgcat 1.7.0 +package provide msgcat 1.7.1 namespace eval msgcat { namespace export mc mcn mcexists mcload mclocale mcmax\ @@ -360,17 +360,19 @@ proc msgcat::mclocale {args} { proc msgcat::mcutil::getpreferences {locale} { set locale [string tolower $locale] - set loclist [list $locale] - while {-1 !=[set pos [string last "_" $locale]]} { - set locale [string range $locale 0 $pos-1] - if { "_" ne [string index $locale end] } { - lappend loclist $locale + set loclist {} + set locel {} + foreach el [split $locale _] { + if {[string index $locel end] != {_}} { + set loclist [linsert $loclist 0 $locel] + } + if {$locel != {}} { + set locel ${locel}_${el} + } else { + set locel ${el} } } - if {"" ne [lindex $loclist end]} { - lappend loclist {} - } - return $loclist + return [linsert $loclist 0 $locel] } # msgcat::mcpreferences -- diff --git a/library/msgcat/pkgIndex.tcl b/library/msgcat/pkgIndex.tcl index 3309a30..18bd71b 100644 --- a/library/msgcat/pkgIndex.tcl +++ b/library/msgcat/pkgIndex.tcl @@ -1,2 +1,2 @@ if {![package vsatisfies [package provide Tcl] 8.7-]} {return} -package ifneeded msgcat 1.7.0 [list source [file join $dir msgcat.tcl]] +package ifneeded msgcat 1.7.1 [list source [file join $dir msgcat.tcl]] |