On Sun, Jan 15, 2017 at 10:17:18AM +0000, Sami Kerola wrote: > This makes --time-format=iso timestamp to look the same as login/logout > times. When --time-format=noformat is used the file creation time not > printed. There is no change to default format. > > Signed-off-by: Sami Kerola <kerolasa@xxxxxx> > --- > login-utils/last.c | 18 +++++++++++++++--- > tests/expected/utmp/last-nodns | 4 +--- > 2 files changed, 16 insertions(+), 6 deletions(-) > > diff --git a/login-utils/last.c b/login-utils/last.c > index 7c243f147..484e18e80 100644 > --- a/login-utils/last.c > +++ b/login-utils/last.c > @@ -874,11 +874,23 @@ static void process_wtmp_file(const struct last_control *ctl, > } > } > > - { > - char* tmp = xstrdup(filename); > - printf(_("\n%s begins %s"), basename(tmp), ctime(&begintime)); > + if (ctl->time_fmt != LAST_TIMEFTM_NONE) { > + struct last_timefmt *fmt; > + char timestr[LAST_TIMESTAMP_LEN]; > + size_t len; > + char *tmp = xstrdup(filename); > + > + fmt = &timefmts[ctl->time_fmt]; > + if (time_formatter(fmt->in_fmt, timestr, > + sizeof(timestr), &begintime) < 0) > + errx(EXIT_FAILURE, _("preallocation size exceeded")); > + len = strlen(timestr) - 1; > + if (timestr[len] == '\n') > + timestr[len] = '\0'; Do we expect this '\n' somewhere in the code? I guess that also for LAST_TIMEFTM_CTIME is the \n char truncated. What about to remove \n from the string in the time_formatter() to avoid this timestr[len] = '\0' in the code? Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html