diff options
author | kennykb <kennykb@noemail.net> | 2004-09-08 18:46:16 (GMT) |
---|---|---|
committer | kennykb <kennykb@noemail.net> | 2004-09-08 18:46:16 (GMT) |
commit | 5011ef876768b0fa88979ed739b0ac49830f9e58 (patch) | |
tree | e15fc5c8dd8792a5d76e1119e59a7a86383b7d7b /compat | |
parent | cdbece6baec1f5197b2e9dd0b34c2bf6ee2d5e34 (diff) | |
download | tcl-5011ef876768b0fa88979ed739b0ac49830f9e58.zip tcl-5011ef876768b0fa88979ed739b0ac49830f9e58.tar.gz tcl-5011ef876768b0fa88979ed739b0ac49830f9e58.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.
FossilOrigin-Name: 5b7d61b147f8d2278c83c2095b9aadc36f77db75
Diffstat (limited to 'compat')
-rw-r--r-- | compat/strftime.c | 14 |
1 files changed, 10 insertions, 4 deletions
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 <time.h> @@ -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)); |