mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
My prevoius commit missed some things. The out_line didn't need
to be padded to 8 chars. Simply make sure that never more than 8 chars are printed ( %-.8s ). The former commit otherwise hosed the width calculation and landed on different positions for the time output. Also the strlen(xx_out_line) hoses the wide calculation, so that it sometimes make it much larger than necessary. Simply use always 8 chars for the out_line calculation now. Looks good this way.
This commit is contained in:
parent
d5a22d48c4
commit
04dc4fc21c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=5239
1 changed files with 3 additions and 2 deletions
|
@ -136,7 +136,8 @@ main(argc, argv)
|
|||
mp = myutmp;
|
||||
width = 0;
|
||||
for (i = 0; i < nusers; i++) {
|
||||
int j = strlen(mp->myhost) + 1 + strlen(mp->myutmp.out_line);
|
||||
/* append one for the blank and use 8 for the out_line */
|
||||
int j = strlen(mp->myhost) + 1 + 8;
|
||||
if (j > width)
|
||||
width = j;
|
||||
mp++;
|
||||
|
@ -144,7 +145,7 @@ main(argc, argv)
|
|||
mp = myutmp;
|
||||
for (i = 0; i < nusers; i++) {
|
||||
char buf[BUFSIZ];
|
||||
(void)sprintf(buf, "%s:%-8.8s", mp->myhost, mp->myutmp.out_line);
|
||||
(void)sprintf(buf, "%s:%-.8s", mp->myhost, mp->myutmp.out_line);
|
||||
printf("%-8.8s %-*s %.12s",
|
||||
mp->myutmp.out_name,
|
||||
width,
|
||||
|
|
Loading…
Reference in a new issue