From 7a44d1f86065f88967089bd5f13f01af23c0f9df Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Tue, 2 Aug 2005 20:52:44 +0000 Subject: [PATCH] Include "xanstrftime.h". (show_date): Use xanstrftime instead of open-coding it. --- src/du.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/src/du.c b/src/du.c index 8ea4ed3354..94410bbee7 100644 --- a/src/du.c +++ b/src/du.c @@ -42,6 +42,7 @@ #include "readtokens0.h" #include "same.h" #include "strftime.h" +#include "xanstrftime.h" #include "xfts.h" #include "xstrtol.h" @@ -412,11 +413,8 @@ hash_init (void) static void show_date (const char *format, time_t when, int nsec) { - struct tm *tm; - char *out = NULL; - size_t out_length = 0; - - tm = localtime (&when); + char *out; + struct tm *tm = localtime (&when); if (! tm) { char buf[INT_BUFSIZE_BOUND (intmax_t)]; @@ -428,18 +426,7 @@ show_date (const char *format, time_t when, int nsec) return; } - do - { - out = X2REALLOC (out, &out_length); - - /* Mark the first byte of the buffer so we can detect the case - of nstrftime producing an empty string. Otherwise, this loop - would not terminate when date was invoked like this - `LANG=de date +%p' on a system with good language support. */ - out[0] = '\1'; - } - while (nstrftime (out, out_length, format, tm, 0, nsec) == 0 && out[0]); - + out = xanstrftime (format, tm, 0, nsec); fputs (out, stdout); free (out); } -- 2.47.3