]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
write: don't use strftime()
authorKarel Zak <kzak@redhat.com>
Thu, 14 Jul 2016 11:20:58 +0000 (13:20 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 14 Jul 2016 11:20:58 +0000 (13:20 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
term-utils/write.c

index 6bd393441e0e6142ebfe624458543124450cdb79..e39b848eaef699e1c5ed3afb1c82b24d877b73ac 100644 (file)
@@ -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");