diff options
author | Sami Kerola | 2013-08-28 19:31:48 +0200 |
---|---|---|
committer | Sami Kerola | 2013-08-29 19:14:10 +0200 |
commit | 97bbb5e41c1a41a1306aedc20d2fd4331d58730a (patch) | |
tree | 53f24a2e46cdc5073e57f8f8f5f17b5cd25ebdf2 /login-utils/last.c | |
parent | tests: add last(1) test (diff) | |
download | kernel-qcow2-util-linux-97bbb5e41c1a41a1306aedc20d2fd4331d58730a.tar.gz kernel-qcow2-util-linux-97bbb5e41c1a41a1306aedc20d2fd4331d58730a.tar.xz kernel-qcow2-util-linux-97bbb5e41c1a41a1306aedc20d2fd4331d58730a.zip |
last: trim trailing white spaces
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/last.c')
-rw-r--r-- | login-utils/last.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/login-utils/last.c b/login-utils/last.c index dd0ca4912..73a4b4791 100644 --- a/login-utils/last.c +++ b/login-utils/last.c @@ -349,6 +349,23 @@ static int time_formatter(const struct last_control *ctl, char *dst, } /* + * Remove trailing spaces from a string. + */ +static void trim_trailing_spaces(char *s) +{ + char *p; + + for (p = s; *p; ++p) + continue; + while (p > s && isspace(*--p)) + continue; + if (p > s) + ++p; + *p++ = '\n'; + *p = '\0'; +} + +/* * Show one line of information on screen */ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int what) @@ -490,6 +507,7 @@ static int list(const struct last_control *ctl, struct utmp *p, time_t t, int wh # endif #endif + trim_trailing_spaces(final); /* * Print out "final" string safely. */ |