diff options
author | ache <ache@FreeBSD.org> | 2001-03-21 18:43:49 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2001-03-21 18:43:49 +0000 |
commit | ba9451ee824bda21b42c1f3176409ce84dec625d (patch) | |
tree | 3f78b8c041292d72fca599b69814871322e0cbc1 /usr.bin/finger/lprint.c | |
parent | 7ce0e6c37fe4599d18e9cc31a6dee1be86e9be64 (diff) | |
download | FreeBSD-src-ba9451ee824bda21b42c1f3176409ce84dec625d.zip FreeBSD-src-ba9451ee824bda21b42c1f3176409ce84dec625d.tar.gz |
Don't attempt to parse %c
Diffstat (limited to 'usr.bin/finger/lprint.c')
-rw-r--r-- | usr.bin/finger/lprint.c | 57 |
1 files changed, 34 insertions, 23 deletions
diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c index f990be2..02099fd 100644 --- a/usr.bin/finger/lprint.c +++ b/usr.bin/finger/lprint.c @@ -47,6 +47,7 @@ static const char rcsid[] = #include <db.h> #include <err.h> #include <fcntl.h> +#include <langinfo.h> #include <paths.h> #include <pwd.h> #include <stdio.h> @@ -106,9 +107,10 @@ lprint(pn) register int cpr, len, maxlen; struct tm *tp; int oddfield; - char *tzn; char t[80]; + if (d_first < 0) + d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); /* * long format -- * login name @@ -173,10 +175,10 @@ lprint(pn) for (w = pn->whead; w != NULL; w = w->next) { if (w->info == LOGGEDIN) { tp = localtime(&w->loginat); - strftime(t, sizeof(t), "%c", tp); - tzn = tp->tm_zone; - cpr = printf("On since %.16s (%s) on %s", - t, tzn, w->tty); + strftime(t, sizeof(t), + d_first ? "%a %e %b %R (%Z)" : "%a %b %e %R (%Z)", + tp); + cpr = printf("On since %s on %s", t, w->tty); /* * idle time is tough; if have one, print a comma, * then spaces to pad out the device name, then the @@ -204,15 +206,18 @@ lprint(pn) cpr = printf("Never logged in."); } else { tp = localtime(&w->loginat); - strftime(t, sizeof(t), "%c", tp); - tzn = tp->tm_zone; - if (now - w->loginat > 86400 * 365 / 2) - cpr = - printf("Last login %.16s %.4s (%s) on %s", - t, t + 20, tzn, w->tty); - else - cpr = printf("Last login %.16s (%s) on %s", - t, tzn, w->tty); + if (now - w->loginat > 86400 * 365 / 2) { + strftime(t, sizeof(t), + d_first ? "%a %e %b %R %Y (%Z)" : + "%a %b %e %R %Y (%Z)", + tp); + } else { + strftime(t, sizeof(t), + d_first ? "%a %e %b %R (%Z)" : + "%a %b %e %R (%Z)", + tp); + } + cpr = printf("Last login %s on %s", t, w->tty); } if (*w->host) { if (LINE_LEN < (cpr + 6 + strlen(w->host))) @@ -225,18 +230,24 @@ lprint(pn) printf("No Mail.\n"); else if (pn->mailrecv > pn->mailread) { tp = localtime(&pn->mailrecv); - strftime(t, sizeof(t), "%c", tp); - tzn = tp->tm_zone; - printf("New mail received %.16s %.4s (%s)\n", t, t + 20, tzn); + strftime(t, sizeof(t), + d_first ? "%a %e %b %R %Y (%Z)" : + "%a %b %e %R %Y (%Z)", + tp); + printf("New mail received %s\n", t); tp = localtime(&pn->mailread); - strftime(t, sizeof(t), "%c", tp); - tzn = tp->tm_zone; - printf(" Unread since %.16s %.4s (%s)\n", t, t + 20, tzn); + strftime(t, sizeof(t), + d_first ? "%a %e %b %R %Y (%Z)" : + "%a %b %e %R %Y (%Z)", + tp); + printf(" Unread since %s\n", t); } else { tp = localtime(&pn->mailread); - strftime(t, sizeof(t), "%c", tp); - tzn = tp->tm_zone; - printf("Mail last read %.16s %.4s (%s)\n", t, t + 20, tzn); + strftime(t, sizeof(t), + d_first ? "%a %e %b %R %Y (%Z)" : + "%a %b %e %R %Y (%Z)", + tp); + printf("Mail last read %s\n", t); } } |