summaryrefslogtreecommitdiffstats
path: root/compat/strftime.c
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2004-09-08 18:32:02 (GMT)
committerKevin B Kenny <kennykb@acm.org>2004-09-08 18:32:02 (GMT)
commit70cac415298381ec7a3f978f729a0e0b97aec972 (patch)
tree411867877941d89f82151c47835cc302aa39023b /compat/strftime.c
parenta8f71a729447a54a46df56f612ef6380d2a5a459 (diff)
downloadtcl-70cac415298381ec7a3f978f729a0e0b97aec972.zip
tcl-70cac415298381ec7a3f978f729a0e0b97aec972.tar.gz
tcl-70cac415298381ec7a3f978f729a0e0b97aec972.tar.bz2
* 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.
Diffstat (limited to 'compat/strftime.c')
-rw-r--r--compat/strftime.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/compat/strftime.c b/compat/strftime.c
index dbd7d54..609c193 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.10.2.1 2004/05/18 21:52:56 kennykb Exp $
+ * RCS: @(#) $Id: strftime.c,v 1.10.2.2 2004/09/08 18:32:20 kennykb Exp $
*/
/*
@@ -47,7 +47,7 @@
*/
#if defined(LIBC_SCCS)
-static char *rcsid = "$Id: strftime.c,v 1.10.2.1 2004/05/18 21:52:56 kennykb Exp $";
+static char *rcsid = "$Id: strftime.c,v 1.10.2.2 2004/09/08 18:32:20 kennykb Exp $";
#endif /* LIBC_SCCS */
#include <time.h>
@@ -432,8 +432,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'; --digits;
+ } 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));