w: align header when from lenght is defined

Before this commit header and output was not in sync if
PROCPS_FROMLEN environment variable where defined.  Example of wrong
behavior is below where the last four fields which are skewed.

$ PROCPS_FROMLEN=18 w -f | cat
 12:31:34 up  1:25,  1 user,  load average: 0.03, 0.06, 0.06
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT
sake     tty1     -                  11:06    1:25m  3.76s  0.00s xinit /ho[...]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2012-03-03 12:31:49 +01:00
parent c459346303
commit 031afacb48

2
w.c
View File

@ -436,7 +436,7 @@ int main(int argc, char **argv)
* headers. Try to keep alignment intact. */
printf(_("%-*s TTY "), userlen, _("USER"));
if (from)
printf(_("FROM "));
printf("%-*s", fromlen - 1, _("FROM"));
if (longform)
printf(_(" LOGIN@ IDLE JCPU PCPU WHAT\n"));
else