summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2016-07-14 13:20:58 +0200
committerKarel Zak2016-07-14 13:20:58 +0200
commitaefd6a9d6a6c7626098439a5b9bbf6a9d28528c5 (patch)
treee646ae76082931d5315d506f06f885f20b6a1524
parentMerge branch 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit (diff)
downloadkernel-qcow2-util-linux-aefd6a9d6a6c7626098439a5b9bbf6a9d28528c5.tar.gz
kernel-qcow2-util-linux-aefd6a9d6a6c7626098439a5b9bbf6a9d28528c5.tar.xz
kernel-qcow2-util-linux-aefd6a9d6a6c7626098439a5b9bbf6a9d28528c5.zip
write: don't use strftime()
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--term-utils/write.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/term-utils/write.c b/term-utils/write.c
index 6bd393441..e39b848ea 100644
--- a/term-utils/write.c
+++ b/term-utils/write.c
@@ -244,7 +244,7 @@ static void write_line(char *s)
*/
static void do_write(const struct write_control *ctl)
{
- char *login, *pwuid, timestamp[6];
+ char *login, *pwuid;
struct passwd *pwd;
time_t now;
struct tm *tm;
@@ -274,15 +274,16 @@ static void do_write(const struct write_control *ctl)
now = time((time_t *)NULL);
tm = localtime(&now);
- strftime(timestamp, sizeof(timestamp), "%H:%M", tm);
/* print greeting */
printf("\r\n\a\a\a");
if (strcmp(login, pwuid))
- printf(_("Message from %s@%s (as %s) on %s at %s ..."),
- login, host, pwuid, ctl->src_tty_name, timestamp);
+ printf(_("Message from %s@%s (as %s) on %s at %02d:%02d ..."),
+ login, host, pwuid, ctl->src_tty_name,
+ tm->tm_hour, tm->tm_min);
else
- printf(_("Message from %s@%s on %s at %s ..."),
- login, host, ctl->src_tty_name, timestamp);
+ printf(_("Message from %s@%s on %s at %02d:%02d ..."),
+ login, host, ctl->src_tty_name,
+ tm->tm_hour, tm->tm_min);
free(host);
printf("\r\n");