From 6cabd70c0dad93b763c05c2893f02a868e7dad82 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 21 Jun 2020 17:03:54 +0000 Subject: Rewrite msgcat::mcutil::getpreferences, not depending on 'string last' returning -1 any more --- library/manifest.txt | 2 +- library/msgcat/msgcat.tcl | 22 ++++++++++++---------- library/msgcat/pkgIndex.tcl | 2 +- unix/Makefile.in | 4 ++-- win/Makefile.in | 4 ++-- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/library/manifest.txt b/library/manifest.txt index c1d7d05..5ae0eb7 100644 --- a/library/manifest.txt +++ b/library/manifest.txt @@ -6,7 +6,7 @@ apply {{dir} { set isafe [interp issafe] foreach {safe package version file} { 0 http 2.9.2 {http http.tcl} - 1 msgcat 1.7.0 {msgcat msgcat.tcl} + 1 msgcat 1.7.1 {msgcat msgcat.tcl} 1 opt 0.4.7 {opt optparse.tcl} 0 cookiejar 0.2.0 {cookiejar cookiejar.tcl} 0 tcl::idna 1.0.1 {cookiejar idna.tcl} 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]] diff --git a/unix/Makefile.in b/unix/Makefile.in index 87521ee..e6a7705 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1046,9 +1046,9 @@ install-libraries: libraries @for i in $(TOP_DIR)/library/opt/*.tcl; do \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)/opt0.4"; \ done - @echo "Installing package msgcat 1.7.0 as a Tcl Module" + @echo "Installing package msgcat 1.7.1 as a Tcl Module" @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl \ - "$(MODULE_INSTALL_DIR)/8.7/msgcat-1.7.0.tm" + "$(MODULE_INSTALL_DIR)/8.7/msgcat-1.7.1.tm" @echo "Installing package tcltest 2.5.3 as a Tcl Module" @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl \ "$(MODULE_INSTALL_DIR)/8.5/tcltest-2.5.3.tm" diff --git a/win/Makefile.in b/win/Makefile.in index 2851e4c..344db71 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -885,8 +885,8 @@ install-libraries: libraries install-tzdata install-msgs do \ $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \ done; - @echo "Installing package msgcat 1.7.0 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl "$(MODULE_INSTALL_DIR)/8.7/msgcat-1.7.0.tm"; + @echo "Installing package msgcat 1.7.1 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl "$(MODULE_INSTALL_DIR)/8.7/msgcat-1.7.1.tm"; @echo "Installing package tcltest 2.5.3 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl "$(MODULE_INSTALL_DIR)/8.5/tcltest-2.5.3.tm"; @echo "Installing package platform 1.0.14 as a Tcl Module"; -- cgit v0.12