From 80ed2d3225fd713abeabba326c657ee9567dc1c5 Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Thu, 29 Oct 2009 01:17:02 +0000 Subject: * library/clock.tcl (LocalizeFormat): * tests/clock.test (clock-67.1): Corrected a problem where '%%' followed by a letter in a format group could expand recursively: %%R would turn into %%H:%M:%S. [Bug 2819334] --- ChangeLog | 7 +++++++ library/clock.tcl | 41 ++++++++++++++++++++++------------------- tests/clock.test | 6 +++++- 3 files changed, 34 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5f72dcb..e3bfe24 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-10-29 Kevin B. Kenny + + * library/clock.tcl (LocalizeFormat): + * tests/clock.test (clock-67.1): + Corrected a problem where '%%' followed by a letter in a format group + could expand recursively: %%R would turn into %%H:%M:%S. [Bug 2819334] + 2009-10-28 Don Porter * generic/tclLiteral.c: Backport fix for [Bug 2888044]. diff --git a/library/clock.tcl b/library/clock.tcl index 9bf41ec..4e7df31 100644 --- a/library/clock.tcl +++ b/library/clock.tcl @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.tcl,v 1.47.2.8 2009/10/27 03:24:17 kennykb Exp $ +# RCS: @(#) $Id: clock.tcl,v 1.47.2.9 2009/10/29 01:17:03 kennykb Exp $ # #---------------------------------------------------------------------- @@ -2563,25 +2563,28 @@ proc ::tcl::clock::LocalizeFormat { locale format } { } set inFormat $format - # Handle locale-dependent format groups by mapping them out of - # the input string. Note that the order of the [string map] - # operations is significant because earlier formats can refer - # to later ones; for example %c can refer to %X, which in turn - # can refer to %T. + # Handle locale-dependent format groups by mapping them out of the format + # string. Note that the order of the [string map] operations is + # significant because later formats can refer to later ones; for example + # %c can refer to %X, which in turn can refer to %T. - set format [string map [list %c [mc DATE_TIME_FORMAT] \ - %Ec [mc LOCALE_DATE_TIME_FORMAT]] $format] - set format [string map [list %x [mc DATE_FORMAT] \ - %Ex [mc LOCALE_DATE_FORMAT] \ - %X [mc TIME_FORMAT] \ - %EX [mc LOCALE_TIME_FORMAT]] $format] - set format [string map [list %r [mc TIME_FORMAT_12] \ - %R [mc TIME_FORMAT_24] \ - %T [mc TIME_FORMAT_24_SECS]] $format] - set format [string map [list %D %m/%d/%Y \ - %EY [mc LOCALE_YEAR_FORMAT]\ - %+ {%a %b %e %H:%M:%S %Z %Y}] $format] - + set list { + %% %% + %D %m/%d/%Y + %+ {%a %b %e %H:%M:%S %Z %Y} + } + lappend list %EY [string map $list [mc LOCALE_YEAR_FORMAT]] + lappend list %T [string map $list [mc TIME_FORMAT_24_SECS]] + lappend list %R [string map $list [mc TIME_FORMAT_24]] + lappend list %r [string map $list [mc TIME_FORMAT_12]] + lappend list %X [string map $list [mc TIME_FORMAT]] + lappend list %EX [string map $list [mc LOCALE_TIME_FORMAT]] + lappend list %x [string map $list [mc DATE_FORMAT]] + lappend list %Ex [string map $list [mc LOCALE_DATE_FORMAT]] + lappend list %c [string map $list [mc DATE_TIME_FORMAT]] + lappend list %Ec [string map $list [mc LOCALE_DATE_TIME_FORMAT]] + set format [string map $list $format] + dict set McLoaded $locale FORMAT $inFormat $format return $format } diff --git a/tests/clock.test b/tests/clock.test index bb284c4..86fad72 100644 --- a/tests/clock.test +++ b/tests/clock.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: clock.test,v 1.83.2.8 2009/10/27 03:24:17 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.83.2.9 2009/10/29 01:17:03 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -36746,6 +36746,10 @@ test clock-66.1 {clock scan, no date, never-before-seen timezone} {*}{ -result 1256572800 } +test clock-67.1 {clock format, %% with a letter following [Bug 2819334]} { + clock format [clock seconds] -format %%r +} %r + # cleanup namespace delete ::testClock -- cgit v0.12