From 4dbba767c34ef9df1449908d3b71e130ebf74dc5 Mon Sep 17 00:00:00 2001 From: oehhar Date: Wed, 12 Sep 2012 17:42:59 +0000 Subject: tip#404 file locale mcset: mc(fl)(m)set backport from 8.6 --- ChangeLog | 8 ++++ doc/msgcat.n | 91 ++++++++++++++++++++++++++++++++++++--------- library/msgcat/msgcat.tcl | 82 ++++++++++++++++++++++++++++++++++++++-- library/msgcat/pkgIndex.tcl | 2 +- tests/msgcat.test | 44 +++++++++++++++++++++- 5 files changed, 203 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0fed83..4d2d296 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2012-09-07 Harald Oehlmann + + IMPLEMENTATION OF TIP#404. + + * library/msgcat.tcl: [FRQ 3544988] (Backport from tcl8.6): add commands + [mcflset] and [mcflmset] to set mc entries with implicit message file + locale. Package version is now 1.5.0. + 2012-09-07 Alexandre Ferrieux * unix/tclUnixNotfy.c Backport of 2008-12-12 8.6 commit: Fix diff --git a/doc/msgcat.n b/doc/msgcat.n index c2c0abd..af6be7f 100644 --- a/doc/msgcat.n +++ b/doc/msgcat.n @@ -13,7 +13,7 @@ msgcat \- Tcl message catalog .SH SYNOPSIS \fBpackage require Tcl 8.5\fR .sp -\fBpackage require msgcat 1.4.5\fR +\fBpackage require msgcat 1.5.0\fR .sp \fB::msgcat::mc \fIsrc-string\fR ?\fIarg arg ...\fR? .sp @@ -29,6 +29,12 @@ msgcat \- Tcl message catalog .sp \fB::msgcat::mcmset \fIlocale src-trans-list\fR .sp +.VS "TIP 404" +\fB::msgcat::mcflset \fIsrc-string \fR?\fItranslate-string\fR? +.sp +\fB::msgcat::mcflmset \fIsrc-trans-list\fR +.VE "TIP 404" +.sp \fB::msgcat::mcunknown \fIlocale src-string\fR .BE .SH DESCRIPTION @@ -49,6 +55,7 @@ wishes to be enabled for multi-lingual applications. .SH COMMANDS .TP \fB::msgcat::mc \fIsrc-string\fR ?\fIarg arg ...\fR? +. Returns a translation of \fIsrc-string\fR according to the user's current locale. If additional arguments past \fIsrc-string\fR are given, the \fBformat\fR command is used to substitute the @@ -71,12 +78,14 @@ later simply by defining new message catalog entries. .RE .TP \fB::msgcat::mcmax ?\fIsrc-string src-string ...\fR? +. Given several source strings, \fB::msgcat::mcmax\fR returns the length of the longest translated string. This is useful when designing localized GUIs, which may require that all buttons, for example, be a fixed width (which will be the width of the widest button). .TP -\fB::msgcat::mclocale \fR?\fInewLocale\fR? +\fB::msgcat::mclocale \fR?\fInewLocale\fR? +. This function sets the locale to \fInewLocale\fR. If \fInewLocale\fR is omitted, the current locale is returned, otherwise the current locale is set to \fInewLocale\fR. msgcat stores and compares the locale in a @@ -86,6 +95,7 @@ the user's environment. See \fBLOCALE SPECIFICATION\fR below for a description of the locale string format. .TP \fB::msgcat::mcpreferences\fR +. Returns an ordered list of the locales preferred by the user, based on the user's language specification. The list is ordered from most specific to least @@ -93,11 +103,10 @@ preference. The list is derived from the current locale set in msgcat by \fB::msgcat::mclocale\fR, and cannot be set independently. For example, if the current locale is en_US_funky, then \fB::msgcat::mcpreferences\fR -.VS 1.4 returns \fB{en_US_funky en_US en {}}\fR. -.VE 1.4 .TP \fB::msgcat::mcload \fIdirname\fR +. Searches the specified directory for files that match the language specifications returned by \fB::msgcat::mcpreferences\fR (note that these are all lowercase), extended by the file extension @@ -111,12 +120,14 @@ evaluation. The number of message files which matched the specification and were loaded is returned. .TP \fB::msgcat::mcset \fIlocale src-string \fR?\fItranslate-string\fR? +. Sets the translation for \fIsrc-string\fR to \fItranslate-string\fR in the specified \fIlocale\fR and the current namespace. If \fItranslate-string\fR is not specified, \fIsrc-string\fR is used for both. The function returns \fItranslate-string\fR. .TP \fB::msgcat::mcmset \fIlocale src-trans-list\fR +. Sets the translation for multiple source strings in \fIsrc-trans-list\fR in the specified \fIlocale\fR and the current namespace. @@ -126,7 +137,28 @@ translate-string ...\fR?} \fB::msgcat::mcmset\fR can be significantly faster than multiple invocations of \fB::msgcat::mcset\fR. The function returns the number of translations set. .TP +\fB::msgcat::mcflset \fIsrc-string \fR?\fItranslate-string\fR? +.VS "TIP 404" +Sets the translation for \fIsrc-string\fR to \fItranslate-string\fR in the +current namespace for the locale implied by the name of the message catalog +being loaded via \fB::msgcat::mcload\fR. If \fItranslate-string\fR is not +specified, \fIsrc-string\fR is used for both. The function returns +\fItranslate-string\fR. +.VE "TIP 404" +.TP +\fB::msgcat::mcflmset \fIsrc-trans-list\fR +.VS "TIP 404" +Sets the translation for multiple source strings in \fIsrc-trans-list\fR in +the current namespace for the locale implied by the name of the message +catalog being loaded via \fB::msgcat::mcload\fR. \fIsrc-trans-list\fR must +have an even number of elements and is in the form {\fIsrc-string +translate-string\fR ?\fIsrc-string translate-string ...\fR?} +\fB::msgcat::mcflmset\fR can be significantly faster than multiple invocations +of \fB::msgcat::mcflset\fR. The function returns the number of translations set. +.VE "TIP 404" +.TP \fB::msgcat::mcunknown \fIlocale src-string\fR +. This routine is called by \fB::msgcat::mc\fR in the case when a translation for \fIsrc-string\fR is not defined in the current locale. The default action is to return @@ -157,14 +189,18 @@ according to the user's environment. The variables \fBenv(LC_ALL)\fR, \fBenv(LC_MESSAGES)\fR, and \fBenv(LANG)\fR are examined in order. The first of them to have a non-empty value is used to determine the initial locale. The value is parsed according to the XPG4 pattern +.PP .CS language[_country][.codeset][@modifier] .CE +.PP to extract its parts. The initial locale is then set by calling \fB::msgcat::mclocale\fR with the argument +.PP .CS language[_country][_modifier] .CE +.PP On Windows and Cygwin, if none of those environment variables is set, msgcat will attempt to extract locale information from the registry. From Windows Vista on, the RFC4747 locale name "lang-script-country-options" @@ -179,7 +215,6 @@ When a locale is specified by the user, a .QW "best match" search is performed during string translation. For example, if a user specifies -.VS 1.4 en_GB_Funky, the locales .QW en_GB_Funky , .QW en_GB , @@ -187,7 +222,6 @@ en_GB_Funky, the locales and .MT (the empty string) -.VE 1.4 are searched in order until a matching translation string is found. If no translation string is available, then \fB::msgcat::mcunknown\fR is called. @@ -201,15 +235,18 @@ source string to be shorter and less prone to typographical error. .PP For example, executing the code +.PP .CS \fB::msgcat::mcset\fR en hello "hello from ::" namespace eval foo { - \fB::msgcat::mcset\fR en hello "hello from ::foo" + \fB::msgcat::mcset\fR en hello "hello from ::foo" } puts [\fB::msgcat::mc\fR hello] namespace eval foo {puts [\fB::msgcat::mc\fR hello]} .CE +.PP will print +.PP .CS hello from :: hello from ::foo @@ -225,23 +262,26 @@ messages from their parent namespace. For example, executing (in the .QW en locale) the code +.PP .CS \fB::msgcat::mcset\fR en m1 ":: message1" \fB::msgcat::mcset\fR en m2 ":: message2" \fB::msgcat::mcset\fR en m3 ":: message3" namespace eval ::foo { - \fB::msgcat::mcset\fR en m2 "::foo message2" - \fB::msgcat::mcset\fR en m3 "::foo message3" + \fB::msgcat::mcset\fR en m2 "::foo message2" + \fB::msgcat::mcset\fR en m3 "::foo message3" } namespace eval ::foo::bar { - \fB::msgcat::mcset\fR en m3 "::foo::bar message3" + \fB::msgcat::mcset\fR en m3 "::foo::bar message3" } namespace import \fB::msgcat::mc\fR puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]" namespace eval ::foo {puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"} namespace eval ::foo::bar {puts "[\fBmc\fR m1]; [\fBmc\fR m2]; [\fBmc\fR m3]"} .CE +.PP will print +.PP .CS :: message1; :: message2; :: message3 :: message1; ::foo message2; ::foo message3 @@ -257,11 +297,12 @@ All message files for a package are in the same directory. The message file name is a msgcat locale specifier (all lowercase) followed by .QW .msg . For example: +.PP .CS es.msg \(em spanish en_gb.msg \(em United Kingdom English .CE -.VS 1.4 +.PP \fIException:\fR The message file for the root locale .MT is called @@ -270,16 +311,16 @@ This exception is made so as not to cause peculiar behavior, such as marking the message file as .QW hidden on Unix file systems. -.VE 1.4 .IP [3] -The file contains a series of calls to \fBmcset\fR and -\fBmcmset\fR, setting the necessary translation strings +The file contains a series of calls to \fBmcflset\fR and +\fBmcflmset\fR, setting the necessary translation strings for the language, likely enclosed in a \fBnamespace eval\fR so that all source strings are tied to the namespace of the package. For example, a short \fBes.msg\fR might contain: +.PP .CS namespace eval ::mypackage { - \fB::msgcat::mcset\fR es "Free Beer!" "Cerveza Gracias!" + \fB::msgcat::mcflset\fR "Free Beer!" "Cerveza Gracias!" } .CE .SH "RECOMMENDED MESSAGE SETUP FOR PACKAGES" @@ -293,8 +334,8 @@ During package installation, create a subdirectory .IP [2] Copy your *.msg files into that directory. .IP [3] - Add the following command to your package -initialization script: +Add the following command to your package initialization script: +.PP .CS # load language files, stored in msgs subdirectory \fB::msgcat::mcload\fR [file join [file dirname [info script]] msgs] @@ -306,6 +347,7 @@ to \fBformat\fR might have positionally dependent parameters that might need to be repositioned. For example, it might be syntactically desirable to rearrange the sentence structure while translating. +.PP .CS format "We produced %d units in location %s" $num $city format "In location %s we produced %d units" $city $num @@ -313,13 +355,23 @@ format "In location %s we produced %d units" $city $num .PP This can be handled by using the positional parameters: +.PP .CS format "We produced %1\e$d units in location %2\e$s" $num $city format "In location %2\e$s we produced %1\e$d units" $num $city .CE .PP Similarly, positional parameters can be used with \fBscan\fR to -extract values from internationalized strings. +extract values from internationalized strings. Note that it is not +necessary to pass the output of \fB::msgcat::mc\fR to \fBformat\fR +directly; by passing the values to substitute in as arguments, the +formatting substitution is done directly. +.PP +.CS +\fBmsgcat::mc\fR {Produced %1$d at %2$s} $num $city +# ... where that key is mapped to one of the +# human-oriented versions by \fBmsgcat::mcset\fR +.CE .SH CREDITS .PP The message catalog code was developed by Mark Harrison. @@ -327,3 +379,6 @@ The message catalog code was developed by Mark Harrison. format(n), scan(n), namespace(n), package(n) .SH KEYWORDS internationalization, i18n, localization, l10n, message, text, translation +.\" Local Variables: +.\" mode: nroff +.\" End: diff --git a/library/msgcat/msgcat.tcl b/library/msgcat/msgcat.tcl index 3377b47..112507a 100644 --- a/library/msgcat/msgcat.tcl +++ b/library/msgcat/msgcat.tcl @@ -13,11 +13,11 @@ package require Tcl 8.5 # When the version number changes, be sure to update the pkgIndex.tcl file, # and the installation directory in the Makefiles. -package provide msgcat 1.4.5 +package provide msgcat 1.5.0 namespace eval msgcat { namespace export mc mcload mclocale mcmax mcmset mcpreferences mcset \ - mcunknown + mcunknown mcflset mcflmset # Records the current locale as passed to mclocale variable Locale "" @@ -25,6 +25,9 @@ namespace eval msgcat { # Records the list of locales to search variable Loclist {} + # Records the locale of the currently sourced message catalogue file + variable FileLocale + # Records the mapping between source strings and translated strings. The # dict key is of the form " ", where locale and # namespace should be themselves dict values and the value is @@ -277,6 +280,11 @@ proc msgcat::mcpreferences {} { # Returns the number of message catalogs that were loaded. proc msgcat::mcload {langdir} { + variable FileLocale + # Save the file locale if we are recursively called + if {[info exists FileLocale]} { + set nestedFileLocale $FileLocale + } set x 0 foreach p [mcpreferences] { if { $p eq {} } { @@ -285,9 +293,17 @@ proc msgcat::mcload {langdir} { set langfile [file join $langdir $p.msg] if {[file exists $langfile]} { incr x + set FileLocale [string tolower [file tail [file rootname $langfile]]] + if {"root" eq $FileLocale} { + set FileLocale "" + } uplevel 1 [list ::source -encoding utf-8 $langfile] + unset FileLocale } } + if {[info exists nestedFileLocale]} { + set FileLocale $nestedFileLocale + } return $x } @@ -318,6 +334,35 @@ proc msgcat::mcset {locale src {dest ""}} { return $dest } +# msgcat::mcflset -- +# +# Set the translation for a given string in the current file locale. +# +# Arguments: +# src The source string. +# dest (Optional) The translated string. If omitted, +# the source string is used. +# +# Results: +# Returns the new locale. + +proc msgcat::mcflset {src {dest ""}} { + variable FileLocale + variable Msgs + + if {![info exists FileLocale]} { + return -code error \ + "must only be used inside a message catalog loaded with ::msgcat::mcload" + } + if {[llength [info level 0]] == 2} { ;# dest not specified + set dest $src + } + + set ns [uplevel 1 [list ::namespace current]] + dict set Msgs $FileLocale $ns $src $dest + return $dest +} + # msgcat::mcmset -- # # Set the translation for multiple strings in a specified locale. @@ -345,7 +390,38 @@ proc msgcat::mcmset {locale pairs } { dict set Msgs $locale $ns $src $dest } - return $length + return [expr {$length / 2}] +} + +# msgcat::mcflmset -- +# +# Set the translation for multiple strings in the mc file locale. +# +# Arguments: +# pairs One or more src/dest pairs (must be even length) +# +# Results: +# Returns the number of pairs processed + +proc msgcat::mcflmset {pairs} { + variable FileLocale + variable Msgs + + if {![info exists FileLocale]} { + return -code error \ + "must only be used inside a message catalog loaded with ::msgcat::mcload" + } + set length [llength $pairs] + if {$length % 2} { + return -code error "bad translation list:\ + should be \"[lindex [info level 0] 0] locale {src dest ...}\"" + } + + set ns [uplevel 1 [list ::namespace current]] + foreach {src dest} $pairs { + dict set Msgs $FileLocale $ns $src $dest + } + return [expr {$length / 2}] } # msgcat::mcunknown -- diff --git a/library/msgcat/pkgIndex.tcl b/library/msgcat/pkgIndex.tcl index 60c2d3c..832bf81 100644 --- a/library/msgcat/pkgIndex.tcl +++ b/library/msgcat/pkgIndex.tcl @@ -1,2 +1,2 @@ if {![package vsatisfies [package provide Tcl] 8.5]} {return} -package ifneeded msgcat 1.4.5 [list source [file join $dir msgcat.tcl]] +package ifneeded msgcat 1.5.0 [list source [file join $dir msgcat.tcl]] diff --git a/tests/msgcat.test b/tests/msgcat.test index bbcd023..d75bf8e 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -17,8 +17,8 @@ if {[catch {package require tcltest 2}]} { puts stderr "Skipping tests in [info script]. tcltest 2 required." return } -if {[catch {package require msgcat 1.4.5}]} { - puts stderr "Skipping tests in [info script]. No msgcat 1.4.5 found to test." +if {[catch {package require msgcat 1.5.0}]} { + puts stderr "Skipping tests in [info script]. No msgcat 1.5.0 found to test." return } @@ -611,6 +611,46 @@ namespace eval ::msgcat::test { mc "this is a %s" "good test" } -result "this is a good test" + # Tests msgcat-8.*: [mcflset] + + set msgdir1 [makeDirectory msgdir1] + makeFile {::msgcat::mcflset k1 v1} l1.msg $msgdir1 + + test msgcat-8.1 {mcflset} -setup { + variable locale [mclocale] + mclocale l1 + mcload $msgdir1 + } -cleanup { + mclocale $locale + } -body { + mc k1 + } -result v1 + + removeFile l1.msg $msgdir1 + removeDirectory msgdir1 + + set msgdir2 [makeDirectory msgdir2] + set msgdir3 [makeDirectory msgdir3] + makeFile "::msgcat::mcflset k2 v2 ; ::msgcat::mcload [list $msgdir3]"\ + l2.msg $msgdir2 + makeFile {::msgcat::mcflset k3 v3} l2.msg $msgdir3 + + # chained mcload + test msgcat-8.2 {mcflset} -setup { + variable locale [mclocale] + mclocale l2 + mcload $msgdir2 + } -cleanup { + mclocale $locale + } -body { + return [mc k2][mc k3] + } -result v2v3 + + removeFile l2.msg $msgdir2 + removeDirectory msgdir2 + removeFile l3.msg $msgdir3 + removeDirectory msgdir3 + cleanupTests } namespace delete ::msgcat::test -- cgit v0.12 From fd70297b820fcad022629bfd4d0ff5e1a550aaaa Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 17 Sep 2012 06:42:02 +0000 Subject: Correct build version and backported 973091ef75 --- ChangeLog | 8 +++++--- changes | 3 +++ tests/msgcat.test | 7 +++++++ unix/Makefile.in | 4 ++-- win/Makefile.in | 4 ++-- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4d2d296..9f63bc1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,9 +2,11 @@ IMPLEMENTATION OF TIP#404. - * library/msgcat.tcl: [FRQ 3544988] (Backport from tcl8.6): add commands - [mcflset] and [mcflmset] to set mc entries with implicit message file - locale. Package version is now 1.5.0. + * library/msgcat/msgcat.tcl: [FRQ 3544988]: (Backport from Tcl 8.6) + * library/msgcat/pkgIndex.tcl: New commands [mcflset] and [mcflmset] + * unix/Makefile.in: to set mc entries with implicit message + * win/Makefile.in: file locale. Bump to 1.5.0. + * tests/msgcat.test: 2012-09-07 Alexandre Ferrieux diff --git a/changes b/changes index 6709726..3221846 100644 --- a/changes +++ b/changes @@ -7655,6 +7655,9 @@ and Tcl_FSMountsChanged(). (porter) 2012-07-25 (bug fix)[3546275] [auto_execok] search match [exec] (danckaert) +2012-09-12 (TIP 404) New msgcat commands [mcflset], [mcflmset] (oehlmann) +=> msgcat 1.5.0 + Many revisions to better support a Cygwin environment (nijtmans) --- Released 8.5.12, July 27, 2011 --- See ChangeLog for details --- diff --git a/tests/msgcat.test b/tests/msgcat.test index d75bf8e..0edb1d2 100644 --- a/tests/msgcat.test +++ b/tests/msgcat.test @@ -56,6 +56,13 @@ namespace eval ::msgcat::test { set result [string tolower \ [msgcat::ConvertLocale $::tcl::mac::locale]] } else { + if {([info sharedlibextension] == ".dll") + && ![catch {package require registry}]} { + # Windows and Cygwin have other ways to determine the + # locale when the environment variables are missing + # and the registry package is present + continue + } set result c } } diff --git a/unix/Makefile.in b/unix/Makefile.in index bdcbda0..a2d89aa 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -773,8 +773,8 @@ install-libraries: libraries $(INSTALL_TZDATA) install-msgs do \ $(INSTALL_DATA) $$i "$(SCRIPT_INSTALL_DIR)"/opt0.4; \ done; - @echo "Installing package msgcat 1.4.5 as a Tcl Module"; - @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.4.5.tm; + @echo "Installing package msgcat 1.5.0 as a Tcl Module"; + @$(INSTALL_DATA) $(TOP_DIR)/library/msgcat/msgcat.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/msgcat-1.5.0.tm; @echo "Installing package tcltest 2.3.4 as a Tcl Module"; @$(INSTALL_DATA) $(TOP_DIR)/library/tcltest/tcltest.tcl "$(SCRIPT_INSTALL_DIR)"/../tcl8/8.5/tcltest-2.3.4.tm; diff --git a/win/Makefile.in b/win/Makefile.in index 8e01818..b0bdec8 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -644,8 +644,8 @@ install-libraries: libraries install-tzdata install-msgs do \ $(COPY) "$$j" "$(SCRIPT_INSTALL_DIR)/opt0.4"; \ done; - @echo "Installing package msgcat 1.4.5 as a Tcl Module"; - @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.4.5.tm; + @echo "Installing package msgcat 1.5.0 as a Tcl Module"; + @$(COPY) $(ROOT_DIR)/library/msgcat/msgcat.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/msgcat-1.5.0.tm; @echo "Installing package tcltest 2.3.4 as a Tcl Module"; @$(COPY) $(ROOT_DIR)/library/tcltest/tcltest.tcl $(SCRIPT_INSTALL_DIR)/../tcl8/8.5/tcltest-2.3.4.tm; @echo "Installing package platform 1.0.10 as a Tcl Module"; -- cgit v0.12 From 301282088d6b7961c502f111c171db6e6a341ab9 Mon Sep 17 00:00:00 2001 From: max Date: Wed, 26 Sep 2012 21:02:33 +0000 Subject: Workaround for [socket -server foo -myaddr localhost 0] failure on OSX. --- ChangeLog | 6 ++++++ generic/tclIOSock.c | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d18242..9f10890 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-09-26 Reinhard Max + + * generic/tclIOSock.c (TclCreateSocketAddress): Work around a bug + in getaddrinfo() on OSX that caused name resolution to fail for + [socket -server foo -myaddr localhost 0]. + 2012-09-20 Jan Nijtmans * win/configure.in: New import libraries for zlib 1.2.7, diff --git a/generic/tclIOSock.c b/generic/tclIOSock.c index e603c91..694501f 100644 --- a/generic/tclIOSock.c +++ b/generic/tclIOSock.c @@ -151,7 +151,7 @@ TclCreateSocketAddress( struct addrinfo *p; struct addrinfo *v4head = NULL, *v4ptr = NULL; struct addrinfo *v6head = NULL, *v6ptr = NULL; - char *native = NULL, portstring[TCL_INTEGER_SPACE]; + char *native = NULL, portbuf[TCL_INTEGER_SPACE], *portstring; const char *family = NULL; Tcl_DString ds; int result, i; @@ -159,7 +159,18 @@ TclCreateSocketAddress( if (host != NULL) { native = Tcl_UtfToExternalDString(NULL, host, -1, &ds); } - TclFormatInt(portstring, port); + + /* + * Workaround for OSX's apparent inability to resolve "localhost", "0" + * when the loopback device is the only available network interface. + */ + if (host != NULL && port == 0) { + portstring = NULL; + } else { + TclFormatInt(portbuf, port); + portstring = portbuf; + } + (void) memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_UNSPEC; -- cgit v0.12 From 309512eff1f0750be76d3bbd487dd734f8eea65b Mon Sep 17 00:00:00 2001 From: dgp Date: Tue, 2 Oct 2012 16:08:42 +0000 Subject: Fix for core bug yet to be named/numbered. --- generic/tclIO.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/generic/tclIO.c b/generic/tclIO.c index 4e24533..0cb9fa9 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -879,19 +879,25 @@ CheckForStdChannelsBeingClosed( ChannelState *statePtr = ((Channel *) chan)->state; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - if ((chan == tsdPtr->stdinChannel) && tsdPtr->stdinInitialized) { + if (tsdPtr->stdinInitialized + && tsdPtr->stdinChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdinChannel)->state) { if (statePtr->refCount < 2) { statePtr->refCount = 0; tsdPtr->stdinChannel = NULL; return; } - } else if ((chan == tsdPtr->stdoutChannel) && tsdPtr->stdoutInitialized) { + } else if (tsdPtr->stdoutInitialized + && tsdPtr->stdoutChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdoutChannel)->state) { if (statePtr->refCount < 2) { statePtr->refCount = 0; tsdPtr->stdoutChannel = NULL; return; } - } else if ((chan == tsdPtr->stderrChannel) && tsdPtr->stderrInitialized) { + } else if (tsdPtr->stderrInitialized + && tsdPtr->stderrChannel != NULL + && statePtr == ((Channel *)tsdPtr->stderrChannel)->state) { if (statePtr->refCount < 2) { statePtr->refCount = 0; tsdPtr->stderrChannel = NULL; -- cgit v0.12 From 570d1f597600fd4e019636e74fc5d1a74bc0b53e Mon Sep 17 00:00:00 2001 From: dgp Date: Wed, 3 Oct 2012 15:22:15 +0000 Subject: When checking for std channels being closed, compare the channel state, not the channel itself so that stacked channels do not cause trouble. --- ChangeLog | 6 ++++++ generic/tclIO.c | 44 ++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8b9f2b..6f84707 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2012-10-03 Don Porter + + * generic/tclIO.c: When checking for std channels being closed, + compare the channel state, not the channel itself so that stacked + channels do not cause trouble. + 2012-08-17 Jan Nijtmans * win/nmakehlp.c: Add "-V" option, in order to be able diff --git a/generic/tclIO.c b/generic/tclIO.c index b9cd30c..eace472 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -697,26 +697,30 @@ CheckForStdChannelsBeingClosed(chan) ChannelState *statePtr = ((Channel *) chan)->state; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - if ((chan == tsdPtr->stdinChannel) && (tsdPtr->stdinInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stdinChannel = NULL; - return; - } - } else if ((chan == tsdPtr->stdoutChannel) - && (tsdPtr->stdoutInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stdoutChannel = NULL; - return; - } - } else if ((chan == tsdPtr->stderrChannel) - && (tsdPtr->stderrInitialized)) { - if (statePtr->refCount < 2) { - statePtr->refCount = 0; - tsdPtr->stderrChannel = NULL; - return; - } + if (tsdPtr->stdinInitialized + && tsdPtr->stdinChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdinChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stdinChannel = NULL; + return; + } + } else if (tsdPtr->stdoutInitialized + && tsdPtr->stdoutChannel != NULL + && statePtr == ((Channel *)tsdPtr->stdoutChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stdoutChannel = NULL; + return; + } + } else if (tsdPtr->stderrInitialized + && tsdPtr->stderrChannel != NULL + && statePtr == ((Channel *)tsdPtr->stderrChannel)->state) { + if (statePtr->refCount < 2) { + statePtr->refCount = 0; + tsdPtr->stderrChannel = NULL; + return; + } } } -- cgit v0.12 From 1484ae31ede8ff92efccc22d56f4ff71806cc55d Mon Sep 17 00:00:00 2001 From: dgp Date: Fri, 5 Oct 2012 16:37:27 +0000 Subject: 3574819 Increase test robustness by creating files in fresh directory to reduce trouble with any existing files in an existing directory. --- tests/fileName.test | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/fileName.test b/tests/fileName.test index 6dd1cb4..51f00d1 100644 --- a/tests/fileName.test +++ b/tests/fileName.test @@ -749,7 +749,7 @@ test filename-11.13 {Tcl_GlobCmd} { } [file join $env(HOME)] set oldpwd [pwd] set oldhome $env(HOME) -cd [temporaryDirectory] +catch {cd [makeDirectory tcl[pid]]} set env(HOME) [pwd] file delete -force globTest file mkdir globTest/a1/b1 @@ -1616,6 +1616,7 @@ catch {file delete -force C:/globTest} cd [temporaryDirectory] file delete -force globTest cd $oldpwd +catch {removeDirectory tcl[pid]} set env(HOME) $oldhome if {[testConstraint testsetplatform]} { testsetplatform $platform -- cgit v0.12 From cf9cce374ed8d3bc405f998d01d9965d224bc482 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sat, 6 Oct 2012 06:13:09 +0000 Subject: [Bug 2459774] win/tcl/Makefile.in not compatible with msys 0.8. --- ChangeLog | 5 +++++ win/Makefile.in | 28 +++++++++++----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ee0b79..6f96a5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-10-06 Jan Nijtmans + + * win/Makefile.in: [Bug 2459774] win/tcl/Makefile.in + not compatible with msys 0.8. + 2012-10-03 Don Porter * generic/tclIO.c: When checking for std channels being closed, diff --git a/win/Makefile.in b/win/Makefile.in index b616737..fad1f09 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -90,7 +90,7 @@ COMPILE_DEBUG_FLAGS = SRC_DIR = @srcdir@ ROOT_DIR = @srcdir@/.. -TOP_DIR = $(shell cd @srcdir@/..; pwd) +TOP_DIR = $(shell cd @srcdir@/..; pwd -P) GENERIC_DIR = $(TOP_DIR)/generic TOMMATH_DIR = $(TOP_DIR)/libtommath WIN_DIR = $(TOP_DIR)/win @@ -112,7 +112,7 @@ ROOT_DIR_NATIVE = $(shell $(CYGPATH) '$(ROOT_DIR)' | sed 's!\\!/!g') # Fully qualify library path so that `make test` # does not depend on the current directory. -LIBRARY_DIR1 = $(shell cd '$(ROOT_DIR_NATIVE)/library' ; pwd) +LIBRARY_DIR1 = $(shell cd '$(ROOT_DIR_NATIVE)/library' ; pwd -P) LIBRARY_DIR = $(shell $(CYGPATH) '$(LIBRARY_DIR1)' | sed 's!\\!/!g') DLLSUFFIX = @DLLSUFFIX@ LIBSUFFIX = @LIBSUFFIX@ @@ -439,12 +439,6 @@ ${TCL_LIB_FILE}: ${TCL_OBJS} ${DDE_OBJS} ${REG_OBJS} @MAKE_LIB@ ${TCL_OBJS} ${DDE_OBJS} ${REG_OBJS} @POST_MAKE_LIB@ -# assume GNU make - -# To enable concurrent parallel make of tcl.dll and tcl.lib, the tcl.dll -# targets have to depend on tcl.lib, this ensures that linking of tcl.dll -# does not execute concurrently with the renaming and recompiling of tcl.lib - ${DDE_DLL_FILE}: ${DDE_OBJS} ${TCL_STUB_LIB_FILE} @MAKE_DLL@ ${DDE_OBJS} $(TCL_STUB_LIB_FILE) $(SHLIB_LD_LIBS) @@ -544,9 +538,9 @@ gendate: # run (and the results checked) after updating to a new release of libtommath. gentommath_h: - $(TCL_EXE) "$(ROOT_DIR_NATIVE)\tools\fix_tommath_h.tcl" \ - "$(TOMMATH_DIR_NATIVE)\tommath.h" \ - > "$(GENERIC_DIR_NATIVE)\tclTomMath.h" + $(TCL_EXE) "$(ROOT_DIR_NATIVE)/tools/fix_tommath_h.tcl" \ + "$(TOMMATH_DIR_NATIVE)/tommath.h" \ + > "$(GENERIC_DIR_NATIVE)/tclTomMath.h" install: all install-binaries install-libraries install-doc install-packages @@ -748,7 +742,7 @@ PKG_CFG_ARGS = @PKG_CFG_ARGS@ PKG_DIR = ./pkgs packages: - @builddir=`pwd`; \ + @builddir=`pwd -P`; \ for i in $(PKGS_DIR)/*; do \ if [ -d $$i ] ; then \ if [ -x $$i/configure ] ; then \ @@ -756,7 +750,7 @@ packages: mkdir -p $(PKG_DIR)/$$pkg; \ if [ ! -f $(PKG_DIR)/$$pkg/Makefile ]; then \ ( cd $(PKG_DIR)/$$pkg; \ - echo "Configuring package '$$i' wd = `pwd`"; \ + echo "Configuring package '$$i' wd = `pwd -P`"; \ $$i/configure --with-tcl=$(PWD) --with-tclinclude=$(GENERIC_DIR) $(PKG_CFG_ARGS) --enable-shared --enable-threads; ) \ fi ; \ echo "Building package '$$pkg'"; \ @@ -767,7 +761,7 @@ packages: cd $$builddir install-packages: packages - @builddir=`pwd`; \ + @builddir=`pwd -P`; \ for i in $(PKGS_DIR)/*; do \ if [ -d $$i ]; then \ pkg=`basename $$i`; \ @@ -780,7 +774,7 @@ install-packages: packages cd $$builddir test-packages: tcltest packages - @builddir=`pwd`; \ + @builddir=`pwd -P`; \ for i in $(PKGS_DIR)/*; do \ if [ -d $$i ]; then \ pkg=`basename $$i`; \ @@ -793,7 +787,7 @@ test-packages: tcltest packages cd $$builddir clean-packages: - @builddir=`pwd`; \ + @builddir=`pwd -P`; \ for i in $(PKGS_DIR)/*; do \ if [ -d $$i ]; then \ pkg=`basename $$i`; \ @@ -805,7 +799,7 @@ clean-packages: cd $$builddir distclean-packages: - @builddir=`pwd`; \ + @builddir=`pwd -P`; \ for i in $(PKGS_DIR)/*; do \ if [ -d $$i ]; then \ pkg=`basename $$i`; \ -- cgit v0.12