From 8dcefe6112800fd9982a5a337440b774fb709ac9 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sat, 4 Feb 2006 14:35:01 +0000 Subject: [PATCH] Remove spurious "union arg" from printf.h Make sure to always print something in the alternate time format. --- include/printf.h | 2 -- lib/libc/stdio/xprintf_time.c | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/printf.h b/include/printf.h index 59fa282cf359..bd862a45a873 100644 --- a/include/printf.h +++ b/include/printf.h @@ -29,8 +29,6 @@ #ifndef _PRINTF_H_ #define _PRINTF_H_ -union arg; - /* * The API defined by glibc allows a renderer to take multiple arguments * This is obviously usable for things like (ptr+len) pairs etc. diff --git a/lib/libc/stdio/xprintf_time.c b/lib/libc/stdio/xprintf_time.c index f50edc3b5e38..81697f165a43 100644 --- a/lib/libc/stdio/xprintf_time.c +++ b/lib/libc/stdio/xprintf_time.c @@ -61,7 +61,7 @@ __printf_render_time(struct __printf_io *io, const struct printf_info *pi, const struct timeval *tv; struct timespec *ts; time_t *tp; - intmax_t t; + intmax_t t, tx; int i, prec, nsec; prec = 0; @@ -82,6 +82,7 @@ __printf_render_time(struct __printf_io *io, const struct printf_info *pi, const p = buf; if (pi->alt) { + tx = t; if (t >= YEAR) { p += sprintf(p, "%jdy", t / YEAR); t %= YEAR; @@ -98,7 +99,7 @@ __printf_render_time(struct __printf_io *io, const struct printf_info *pi, const p += sprintf(p, "%jdm", t / MINUTE); t %= MINUTE; } - if (t != 0) + if (t != 0 || tx == 0) p += sprintf(p, "%jds", t); } else { p += sprintf(p, "%jd", (intmax_t)t);