From b5186ccbd71eab1e579ea64059a994c83e7c7254 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 26 Nov 2006 14:02:17 +0000 Subject: [PATCH] Code cleanup --- src/ls.c | 7 +++++-- src/who.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ls.c b/src/ls.c index 8c3b93e..796717f 100644 --- a/src/ls.c +++ b/src/ls.c @@ -582,14 +582,17 @@ static void _long_date(time_t date, char buf[15]) { struct tm tm; static time_t sixmonths = -1; + size_t len; if(sixmonths == -1) sixmonths = time(NULL) - 15552000; localtime_r(&date, &tm); if(date < sixmonths) - strftime(buf, 14, "%b %e %Y", &tm); + len = strftime(buf, 14, "%b %e %Y", &tm); else - strftime(buf, 14, "%b %e %H:%M", &tm); + len = strftime(buf, 14, "%b %e %H:%M", &tm); + if(len == 0) + buf[0] = '\0'; } static char _file_mode_letter(mode_t mode) diff --git a/src/who.c b/src/who.c index 95cc9df..992335b 100644 --- a/src/who.c +++ b/src/who.c @@ -41,8 +41,8 @@ static int _who(Prefs * prefs) printf(" %c", '?'); printf(" %-8s", u->ut_line); t = u->ut_tv.tv_sec; - if((tm = localtime(&t)) == NULL || strftime(buf, - sizeof(buf), "%b %e %H:%M", tm) == 0) + if((tm = localtime(&t)) == NULL || strftime(buf, sizeof(buf), + "%b %e %H:%M", tm) == 0) strcpy(buf, "n/a"); printf(" %s\n", buf); }