From 650847f3b6562e21662bff6f2eefea5bfb2628d1 Mon Sep 17 00:00:00 2001 From: Kevin B Kenny Date: Wed, 8 Sep 2004 18:46:17 +0000 Subject: * compat/strftime.c (_conv): Corrected a problem where hour 0 would format as a blank format group with %k. * tests/clock.test (clock-41.1): Added regression test case for %k at the zero hour. --- ChangeLog | 7 +++++-- compat/strftime.c | 14 ++++++++++---- tests/clock.test | 6 +++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fd358c..5ad7a97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,11 +6,13 @@ 2004-09-08 Kevin B. Kenny + * compat/strftime.c (_conv): Corrected a problem where hour 0 + would format as a blank format group with %k. * doc/clock.n: Corrected a buglet in the header information. [Bug 1024058] * generic/tclClock.c (TclClockMktimeObjCmd): Fixed a bug where the month was scanned incorrectly in -timezone :localtime. - * tests/clock.test (clock-34.*,clock-40.1): Adjusted the + * tests/clock.test (clock-34.*,clock-40.1, clock-41.1): Adjusted the clock-34.* test cases so that the consistency check is performed in :localtime rather than the current time zone. This change allows dealing with issues where the C library has a different @@ -18,7 +20,8 @@ TclGetDate into separate parser and time converter, and do the time conversion in clock.tcl. That's for another day.) Added regression test case for the bug where month was scanned - incorrectly in -timezone :localtime. + incorrectly in -timezone :localtime. [Bug 1023779] Added + regression test case for %k at the zero hour. 2004-09-07 David Gravereaux diff --git a/compat/strftime.c b/compat/strftime.c index 8204a83..91e7057 100644 --- a/compat/strftime.c +++ b/compat/strftime.c @@ -10,7 +10,7 @@ * * Changes 2002 Copyright (c) 2002 ActiveState Corporation. * - * RCS: @(#) $Id: strftime.c,v 1.16 2004/05/18 21:45:55 kennykb Exp $ + * RCS: @(#) $Id: strftime.c,v 1.17 2004/09/08 18:46:18 kennykb Exp $ */ /* @@ -47,7 +47,7 @@ */ #if defined(LIBC_SCCS) -static char *rcsid = "$Id: strftime.c,v 1.16 2004/05/18 21:45:55 kennykb Exp $"; +static char *rcsid = "$Id: strftime.c,v 1.17 2004/09/08 18:46:18 kennykb Exp $"; #endif /* LIBC_SCCS */ #include @@ -457,8 +457,14 @@ _conv(n, digits, pad) static char buf[10]; register char *p; - for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) - *p-- = (char)(n % 10 + '0'); + p = buf + sizeof( buf ) - 1; + *p-- = '\0'; + if ( n == 0 ) { + *p-- = '0'; + } else { + for (; n > 0 && p > buf; n /= 10, --digits) + *p-- = (char)(n % 10 + '0'); + } while (p > buf && digits-- > 0) *p-- = (char) pad; return(_add(++p)); diff --git a/tests/clock.test b/tests/clock.test index 4057aa2..acb7a6e 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.42 2004/09/08 15:55:43 kennykb Exp $ +# RCS: @(#) $Id: clock.test,v 1.43 2004/09/08 18:46:18 kennykb Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest 2 @@ -35257,6 +35257,10 @@ test clock-40.1 {regression - bad month with -timezone :localtime} \ } \ -result {0} +test clock-41.1 {regression test - format group %k when hour is 0 } { + clock format 0 -format %k -gmt true +} { 0} + # cleanup namespace delete ::testClock -- cgit v0.12